Skip to content

Commit 79ddaaf

Browse files
committed
LinePattern initial idea
1 parent 9a564a1 commit 79ddaaf

File tree

5 files changed

+130
-20
lines changed

5 files changed

+130
-20
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ typings/
5757
# dotenv environment variables file
5858
.env
5959

60+
yarn-error.log
61+
build
62+

components/LinePattern.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@ import React from 'react';
22

33
class LinePattern extends React.Component {
44
render() {
5+
6+
let s = this.props.size;
7+
58
return (
69
<pattern
7-
id="linePattern"
10+
id={this.props.id}
811
patternUnits="userSpaceOnUse"
12+
width={s}
13+
height={s}
914
>
10-
<path d=''/>
15+
<path
16+
d={`
17+
M 0 0 L ${s} ${s}
18+
M ${-s} 0 L ${s} ${2 * s}
19+
M 0 ${-s} L ${2*s} ${s}
20+
`}
21+
stroke='red'
22+
stroke-linecap='square'
23+
stroke-width='5'
24+
/>
1125
</pattern>
1226
);
1327
}

package.json

+11-7
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@
1010
"react-dom": "^16.3.1"
1111
},
1212
"devDependencies": {
13+
"@storybook/addon-actions": "^3.4.1",
14+
"@storybook/addon-links": "^3.4.1",
15+
"@storybook/addons": "^3.4.1",
16+
"@storybook/react": "^3.4.1",
1317
"babel-cli": "^6.26.0",
1418
"babel-core": "^6.26.0",
1519
"babel-plugin-transform-object-rest-spread": "^6.26.0",
1620
"babel-preset-es2015": "^6.24.1",
1721
"babel-preset-react": "^6.24.1",
22+
"npm-run-all": "^4.1.2",
1823
"webpack": "^4.5.0",
1924
"webpack-dev-server": "^3.1.3",
20-
"why-did-you-update": "^0.1.1",
21-
"@storybook/react": "^3.4.1",
22-
"@storybook/addon-actions": "^3.4.1",
23-
"@storybook/addon-links": "^3.4.1",
24-
"@storybook/addons": "^3.4.1"
25+
"why-did-you-update": "^0.1.1"
2526
},
2627
"scripts": {
27-
"storybook": "start-storybook -p 6006",
28-
"build-storybook": "build-storybook"
28+
"start": "npm-run-all --parallel storybook:start build:watch",
29+
"storybook:start": "start-storybook --port 6003",
30+
"storybook:build": "build-storybook",
31+
"build": "babel components -d build --copy-files",
32+
"build:watch": "babel components -d build --copy-files --watch"
2933
}
3034
}

stories/index.stories.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import { storiesOf } from '@storybook/react';
44
import { action } from '@storybook/addon-actions';
55
import { linkTo } from '@storybook/addon-links';
66

7-
import { Button, Welcome } from '@storybook/react/demo';
7+
import LinePattern from '../components/LinePattern';
88

9-
storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
10-
11-
storiesOf('Button', module)
12-
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
13-
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
9+
storiesOf('LinePattern', module)
10+
.add('Basic', () => {
11+
return <svg>
12+
<defs>
13+
<LinePattern id='mypattern' size='20'/>
14+
</defs>
15+
<rect x='0' y='0' width='100%' height='100%' fill="url(#mypattern)"/>
16+
</svg>
17+
});

yarn.lock

+90-5
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ ansi-styles@^2.2.1:
315315
version "2.2.1"
316316
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
317317

318-
ansi-styles@^3.2.1:
318+
ansi-styles@^3.2.0, ansi-styles@^3.2.1:
319319
version "3.2.1"
320320
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
321321
dependencies:
@@ -2162,7 +2162,7 @@ create-react-class@^15.6.2:
21622162
loose-envify "^1.3.1"
21632163
object-assign "^4.1.1"
21642164

2165-
cross-spawn@5.1.0, cross-spawn@^5.0.1:
2165+
cross-spawn@5.1.0, cross-spawn@^5.0.1, cross-spawn@^5.1.0:
21662166
version "5.1.0"
21672167
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
21682168
dependencies:
@@ -2531,7 +2531,7 @@ dotenv@^5.0.1:
25312531
version "5.0.1"
25322532
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef"
25332533

2534-
duplexer@^0.1.1:
2534+
duplexer@^0.1.1, duplexer@~0.1.1:
25352535
version "0.1.1"
25362536
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
25372537

@@ -2770,6 +2770,18 @@ event-emitter@~0.3.5:
27702770
d "1"
27712771
es5-ext "~0.10.14"
27722772

2773+
event-stream@~3.3.0:
2774+
version "3.3.4"
2775+
resolved "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571"
2776+
dependencies:
2777+
duplexer "~0.1.1"
2778+
from "~0"
2779+
map-stream "~0.1.0"
2780+
pause-stream "0.0.11"
2781+
split "0.3"
2782+
stream-combiner "~0.0.4"
2783+
through "~2.3.1"
2784+
27732785
eventemitter3@1.x.x:
27742786
version "1.2.0"
27752787
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508"
@@ -3099,6 +3111,10 @@ from2@^2.1.0:
30993111
inherits "^2.0.1"
31003112
readable-stream "^2.0.0"
31013113

3114+
from@~0:
3115+
version "0.1.7"
3116+
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
3117+
31023118
fs-readdir-recursive@^1.0.0:
31033119
version "1.1.0"
31043120
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
@@ -4109,6 +4125,15 @@ load-json-file@^2.0.0:
41094125
pify "^2.0.0"
41104126
strip-bom "^3.0.0"
41114127

4128+
load-json-file@^4.0.0:
4129+
version "4.0.0"
4130+
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b"
4131+
dependencies:
4132+
graceful-fs "^4.1.2"
4133+
parse-json "^4.0.0"
4134+
pify "^3.0.0"
4135+
strip-bom "^3.0.0"
4136+
41124137
loader-runner@^2.3.0:
41134138
version "2.3.0"
41144139
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2"
@@ -4297,6 +4322,10 @@ map-obj@^1.0.0, map-obj@^1.0.1:
42974322
version "1.0.1"
42984323
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d"
42994324

4325+
map-stream@~0.1.0:
4326+
version "0.1.0"
4327+
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194"
4328+
43004329
map-visit@^1.0.0:
43014330
version "1.0.0"
43024331
resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"
@@ -4342,6 +4371,10 @@ memory-fs@^0.4.0, memory-fs@~0.4.1:
43424371
errno "^0.1.3"
43434372
readable-stream "^2.0.1"
43444373

4374+
memorystream@^0.3.1:
4375+
version "0.3.1"
4376+
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
4377+
43454378
meow@^3.3.0:
43464379
version "3.7.0"
43474380
resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb"
@@ -4665,6 +4698,20 @@ normalize-url@^1.4.0:
46654698
query-string "^4.1.0"
46664699
sort-keys "^1.0.0"
46674700

4701+
npm-run-all@^4.1.2:
4702+
version "4.1.2"
4703+
resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.2.tgz#90d62d078792d20669139e718621186656cea056"
4704+
dependencies:
4705+
ansi-styles "^3.2.0"
4706+
chalk "^2.1.0"
4707+
cross-spawn "^5.1.0"
4708+
memorystream "^0.3.1"
4709+
minimatch "^3.0.4"
4710+
ps-tree "^1.1.0"
4711+
read-pkg "^3.0.0"
4712+
shell-quote "^1.6.1"
4713+
string.prototype.padend "^3.0.0"
4714+
46684715
npm-run-path@^2.0.0:
46694716
version "2.0.2"
46704717
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
@@ -4975,6 +5022,18 @@ path-type@^2.0.0:
49755022
dependencies:
49765023
pify "^2.0.0"
49775024

5025+
path-type@^3.0.0:
5026+
version "3.0.0"
5027+
resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f"
5028+
dependencies:
5029+
pify "^3.0.0"
5030+
5031+
pause-stream@0.0.11:
5032+
version "0.0.11"
5033+
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
5034+
dependencies:
5035+
through "~2.3"
5036+
49785037
pbkdf2@^3.0.3:
49795038
version "3.0.14"
49805039
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.14.tgz#a35e13c64799b06ce15320f459c230e68e73bade"
@@ -5377,6 +5436,12 @@ prr@~1.0.1:
53775436
version "1.0.1"
53785437
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
53795438

5439+
ps-tree@^1.1.0:
5440+
version "1.1.0"
5441+
resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.0.tgz#b421b24140d6203f1ed3c76996b4427b08e8c014"
5442+
dependencies:
5443+
event-stream "~3.3.0"
5444+
53805445
pseudomap@^1.0.2:
53815446
version "1.0.2"
53825447
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
@@ -5664,6 +5729,14 @@ read-pkg@^2.0.0:
56645729
normalize-package-data "^2.3.2"
56655730
path-type "^2.0.0"
56665731

5732+
read-pkg@^3.0.0:
5733+
version "3.0.0"
5734+
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389"
5735+
dependencies:
5736+
load-json-file "^4.0.0"
5737+
normalize-package-data "^2.3.2"
5738+
path-type "^3.0.0"
5739+
56675740
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3:
56685741
version "2.3.6"
56695742
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
@@ -6131,7 +6204,7 @@ shebang-regex@^1.0.0:
61316204
version "1.0.0"
61326205
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
61336206

6134-
shell-quote@1.6.1:
6207+
shell-quote@1.6.1, shell-quote@^1.6.1:
61356208
version "1.6.1"
61366209
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767"
61376210
dependencies:
@@ -6296,6 +6369,12 @@ split-string@^3.0.1, split-string@^3.0.2:
62966369
dependencies:
62976370
extend-shallow "^3.0.0"
62986371

6372+
split@0.3:
6373+
version "0.3.3"
6374+
resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f"
6375+
dependencies:
6376+
through "2"
6377+
62996378
sprintf-js@~1.0.2:
63006379
version "1.0.3"
63016380
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
@@ -6342,6 +6421,12 @@ stream-browserify@^2.0.1:
63426421
inherits "~2.0.1"
63436422
readable-stream "^2.0.2"
63446423

6424+
stream-combiner@~0.0.4:
6425+
version "0.0.4"
6426+
resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14"
6427+
dependencies:
6428+
duplexer "~0.1.1"
6429+
63456430
stream-each@^1.1.0:
63466431
version "1.2.2"
63476432
resolved "https://registry.yarnpkg.com/stream-each/-/stream-each-1.2.2.tgz#8e8c463f91da8991778765873fe4d960d8f616bd"
@@ -6537,7 +6622,7 @@ through2@^2.0.0:
65376622
readable-stream "^2.1.5"
65386623
xtend "~4.0.1"
65396624

6540-
through@^2.3.6, through@^2.3.8, through@~2.3.6:
6625+
through@2, through@^2.3.6, through@^2.3.8, through@~2.3, through@~2.3.1, through@~2.3.6:
65416626
version "2.3.8"
65426627
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
65436628

0 commit comments

Comments
 (0)