-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.0.0 release A.K.A Typescript rewrite (#88)
* Migrate to typescript * Switch build step to Bili * Add eslint config * More cleaning * Switch doc to TS * Fix docs typing * Update dist structure * Update version * try fixing codesandbox ci * Update build package.json file * extends main tsconfig for docs
- Loading branch information
Showing
35 changed files
with
8,229 additions
and
3,938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"sandboxes": ["v69ly910ql"] | ||
"sandboxes": ["v69ly910ql"], | ||
"publishDirectory": { | ||
"react-easy-crop": "dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docs/.cache | ||
dist | ||
.yalc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"react-app", | ||
"prettier", | ||
"prettier/@typescript-eslint", | ||
"prettier/react" | ||
], | ||
"plugins": ["@typescript-eslint/eslint-plugin"], | ||
"rules": { | ||
"@typescript-eslint/explicit-function-return-type": 0, | ||
"@typescript-eslint/ban-ts-ignore": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Config } from 'bili' | ||
|
||
const config: Config = { | ||
input: { | ||
index: 'src/index.tsx', | ||
}, | ||
output: { | ||
format: ['cjs', 'umd', 'umd-min', 'esm'], | ||
moduleName: 'ReactEasyCrop', | ||
sourceMap: true, | ||
}, | ||
globals: { | ||
react: 'React', | ||
}, | ||
extendConfig(config, { format }) { | ||
if (format.startsWith('umd')) { | ||
config.output.fileName = 'umd/react-easy-crop[min].js' | ||
} | ||
if (format === 'esm') { | ||
config.output.fileName = '[name].module.js' | ||
} | ||
return config | ||
}, | ||
env: { | ||
NODE_ENV: 'production', | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import AppBar from '@material-ui/core/AppBar' | ||
import Dialog from '@material-ui/core/Dialog' | ||
import IconButton from '@material-ui/core/IconButton' | ||
import Slide from '@material-ui/core/Slide' | ||
import { createStyles, makeStyles, Theme, useTheme } from '@material-ui/core/styles' | ||
import Toolbar from '@material-ui/core/Toolbar' | ||
import Typography from '@material-ui/core/Typography' | ||
import useMediaQuery from '@material-ui/core/useMediaQuery' | ||
import CloseIcon from '@material-ui/icons/Close' | ||
import React from 'react' | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
appBar: { | ||
position: 'relative', | ||
}, | ||
flex: { | ||
flex: 1, | ||
}, | ||
img: { | ||
display: 'block', | ||
margin: 'auto', | ||
maxWidth: '100%', | ||
maxHeight: '100%', | ||
}, | ||
}) | ||
) | ||
|
||
type Props = { | ||
img: HTMLImageElement['src'] | null | ||
onClose: () => void | ||
} | ||
|
||
function Transition(props) { | ||
return <Slide direction="up" {...props} /> | ||
} | ||
|
||
const ImgDialog = ({ img, onClose, ...rest }: Props) => { | ||
const classes = useStyles(rest) | ||
const theme = useTheme() | ||
const isAtLeastXs = useMediaQuery(theme.breakpoints.up('xs')) | ||
return ( | ||
<Dialog | ||
fullScreen={!isAtLeastXs} | ||
open={!!img} | ||
onClose={onClose} | ||
TransitionComponent={Transition} | ||
> | ||
<AppBar className={classes.appBar}> | ||
<Toolbar> | ||
<IconButton color="inherit" onClick={onClose} aria-label="Close"> | ||
<CloseIcon /> | ||
</IconButton> | ||
<Typography variant="h6" color="inherit" className={classes.flex}> | ||
Cropped image | ||
</Typography> | ||
</Toolbar> | ||
</AppBar> | ||
<img src={img} alt="Cropped" className={classes.img} /> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default ImgDialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.