Skip to content

Commit 2a07ac4

Browse files
authored
Merge pull request #26 from dapilab/fix-build
fix: bundling script
2 parents 7af1cbf + 372abf6 commit 2a07ac4

File tree

11 files changed

+969
-1178
lines changed

11 files changed

+969
-1178
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dev:
1313
.PHONY: lint lint-fix dev
1414

1515
# Test
16-
test: lint-fix
16+
test:
1717
@echo "Running test..."
1818
@npx jest
1919
.PHONY: test

demo/src/App/AvatarEditor/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default class AvatarEditor extends Component {
7878
const { config, shape, download } = this.props
7979
const { isCodeShow } = this.state
8080
return (
81-
<div className="AvatarEditor rounded-full p-3 flex items-center">
81+
<div className="AvatarEditor rounded-full px-3 py-2 flex items-center">
8282
{/* Face */}
8383
<SectionWrapper
8484
className="w-8 h-8 rounded-full p-2 mx-2"
@@ -163,10 +163,10 @@ export default class AvatarEditor extends Component {
163163
})}
164164
data-tip="Config"
165165
onClick={this.toggleCodeShow.bind(this)} />
166-
<div className={classnames("rounded-lg bg-white py-5 px-6 absolute bottom-full codeBlock mb-4", {
166+
<div className={classnames("rounded-lg bg-white p-5 absolute bottom-full codeBlock mb-4", {
167167
active: isCodeShow
168168
})}>
169-
<pre className="text-sm">{this.genCodeString(config)}</pre>
169+
<pre className="text-xs highres:text-sm">{this.genCodeString(config)}</pre>
170170
</div>
171171
</div>
172172

demo/src/App/AvatarList/index.scss

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
@import "~shared-style/mixin";
2+
13
$avatarWidth: 4.5rem;
4+
$laptopWidth: $avatarWidth - 0.8rem;
25
$displayCount: 10;
36
$sectionWidth: $avatarWidth * $displayCount;
47

@@ -7,14 +10,21 @@ $sectionWidth: $avatarWidth * $displayCount;
710
}
811

912
.AvatarList {
10-
width: $sectionWidth;
13+
width: $laptopWidth * $displayCount;
14+
@include breakpoint(highres) {
15+
width: $avatarWidth * $displayCount;
16+
}
1117
.listWrapper {
1218
transition: all 0.35s ease-out;
1319
}
1420

1521
.AvatarItemWrapper {
16-
flex: 0 0 $avatarWidth;
17-
height: $avatarWidth;
22+
flex: 0 0 $laptopWidth;
23+
height: $laptopWidth;
24+
@include breakpoint(highres) {
25+
flex: 0 0 $avatarWidth;
26+
height: $avatarWidth;
27+
}
1828
display: flex;
1929
align-items: center;
2030
justify-content: center;
@@ -24,9 +34,14 @@ $sectionWidth: $avatarWidth * $displayCount;
2434
}
2535
}
2636
& > .AvatarItem {
27-
$avatarWidth: $avatarWidth - 1.5rem;
28-
width: $avatarWidth;
29-
height: $avatarWidth;
37+
$avatarLaptopInnerWidth: $laptopWidth - 1.2rem;
38+
$avatarInnerWidth: $avatarWidth - 1.5rem;
39+
width: $avatarLaptopInnerWidth;
40+
height: $avatarLaptopInnerWidth;
41+
@include breakpoint(highres) {
42+
width: $avatarInnerWidth;
43+
height: $avatarInnerWidth;
44+
}
3045
transition: all 0.25s ease-out;
3146
cursor: pointer;
3247
}

demo/src/App/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class App extends Component<{}, {}> {
6666
id={this.avatarId}
6767
className="mb-10">
6868
<ReactNiceAvatar
69-
className="w-80 h-80"
69+
className="w-64 h-64 highres:w-80 highres:h-80"
7070
hairColorRandom
7171
shape={shape}
7272
{...config} />

demo/src/scss/_mixin.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@mixin breakpoint($class) {
2+
@if $class == tablet {
3+
@media (min-width: 640px) { @content; }
4+
}
5+
@else if $class == laptop {
6+
@media (min-width: 768px) { @content; }
7+
}
8+
@else if $class == desktop {
9+
@media (min-width: 1280px) { @content; }
10+
}
11+
@else if $class == highres {
12+
@media (min-width: 1680px) { @content; }
13+
}
14+
@else if $class == 5k {
15+
@media (min-width: 2000px) { @content; }
16+
}
17+
@else {
18+
@warn "Breakpoint mixin supports: mobile, tablet, desktop, highres";
19+
}
20+
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
"prop-types": "^15.7.2"
2121
},
2222
"devDependencies": {
23+
"@babel/core": "^7.14.3",
2324
"@babel/plugin-proposal-decorators": "^7.14.5",
2425
"@babel/plugin-syntax-async-generators": "^7.8.4",
2526
"@babel/plugin-transform-regenerator": "^7.14.5",
2627
"@babel/plugin-transform-runtime": "^7.15.0",
27-
"@babel/preset-env": "^7.15.0",
28-
"@babel/preset-react": "^7.14.5",
29-
"@babel/preset-typescript": "^7.15.0",
28+
"@babel/preset-env": "^7.14.4",
29+
"@babel/preset-react": "^7.13.13",
30+
"@babel/preset-typescript": "^7.14.5",
3031
"@types/file-saver": "^2.0.3",
3132
"@types/jest": "^26.0.24",
3233
"@types/react": "^17.0.14",
@@ -65,7 +66,6 @@
6566
"terser-webpack-plugin": "^2.1.2",
6667
"ts-jest": "^27.0.4",
6768
"tsconfig-paths-webpack-plugin": "^3.5.1",
68-
"tslib": "^2.3.0",
6969
"typescript": "^4.4.2",
7070
"webpack": "^4.41.0",
7171
"webpack-cli": "^3.3.10",

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface NiceAvatarProps extends AvatarConfig {
4747
shape?: "circle" | "rounded" | "square"
4848
}
4949

50-
export type GenConfigFunc = (config?: AvatarConfig) => Required<AvatarFullConfig>
50+
export type GenConfigFunc = (config?: AvatarFullConfig) => Required<AvatarFullConfig>
5151

5252
export declare const genConfig: GenConfigFunc
5353

src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ export const genConfig: GenConfigFunc = (userConfig = {}) => {
144144
const _hairOrHatColor = response.hatStyle === "none" && response.hairColor || response.hatColor;
145145

146146
// Eyebrow
147-
response.eyeBrowStyle = userConfig.eyeBrowStyle
148-
if (!response.eyeBrowStyle) {
147+
if (userConfig.eyeBrowStyle) {
148+
response.eyeBrowStyle = userConfig.eyeBrowStyle
149+
} else {
149150
response.eyeBrowStyle = response.sex === "woman"
150151
? pickRandomFromList(defaultOptions.eyeBrowWoman)
151152
: "up"

webpack/demo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = merge(baseConfig, {
1616
new TsconfigPathsPlugin({ configFile: path.resolve(__dirname, "../demo/tsconfig.json") })
1717
],
1818
alias: {
19-
"react-nice-avatar": path.resolve(__dirname, "../src")
19+
"react-nice-avatar": path.resolve(__dirname, "../src"),
20+
"shared-style": path.resolve(__dirname, "../demo/src/scss")
2021
}
2122
},
2223
entry: {

webpack/production.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ module.exports = merge(baseConfig, {
1616
]
1717
},
1818
entry: {
19-
app: path.resolve(__dirname, "../src/index.tsx")
19+
index: path.resolve(__dirname, "../src/index.tsx")
2020
},
2121
output: {
2222
filename: "[name].js",
2323
path: path.resolve(__dirname, "../dist"),
24-
publicPath: "/dist/"
24+
libraryTarget: 'commonjs2'
2525
},
2626
plugins: [
2727
new webpack.DefinePlugin({
@@ -33,4 +33,4 @@ module.exports = merge(baseConfig, {
3333
new TerserJSPlugin({ extractComments: false })
3434
]
3535
}
36-
});
36+
});

0 commit comments

Comments
 (0)