@codecademy/gamut-patterns 1.0.0-alpha.b00dca.0 → 1.0.0-alpha.d04966.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.svgo.yml +11 -0
- package/CHANGELOG.md +316 -2
- package/README.md +4 -3
- package/babel.config.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/patterns/CheckerDense.d.ts +3 -0
- package/dist/patterns/CheckerDense.js +47 -0
- package/dist/patterns/CheckerLoose.d.ts +3 -0
- package/dist/patterns/CheckerLoose.js +47 -0
- package/dist/patterns/CheckerRegular.d.ts +3 -0
- package/dist/patterns/CheckerRegular.js +47 -0
- package/dist/patterns/DiagonalADense.d.ts +3 -0
- package/dist/patterns/DiagonalADense.js +81 -0
- package/dist/patterns/DiagonalALoose.d.ts +3 -0
- package/dist/patterns/DiagonalALoose.js +225 -0
- package/dist/patterns/DiagonalARegular.d.ts +3 -0
- package/dist/patterns/DiagonalARegular.js +129 -0
- package/dist/patterns/DiagonalBDense.d.ts +3 -0
- package/dist/patterns/DiagonalBDense.js +63 -0
- package/dist/patterns/DiagonalBLoose.d.ts +3 -0
- package/dist/patterns/DiagonalBLoose.js +131 -0
- package/dist/patterns/DiagonalBRegular.d.ts +3 -0
- package/dist/patterns/DiagonalBRegular.js +87 -0
- package/dist/patterns/DotDense.d.ts +3 -0
- package/dist/patterns/DotDense.js +42 -0
- package/dist/patterns/DotLoose.d.ts +3 -0
- package/dist/patterns/DotLoose.js +85 -0
- package/dist/patterns/DotRegular.d.ts +3 -0
- package/dist/patterns/DotRegular.js +42 -0
- package/dist/patterns/ExDense.d.ts +3 -0
- package/dist/patterns/ExDense.js +64 -0
- package/dist/patterns/ExLoose.d.ts +3 -0
- package/dist/patterns/ExLoose.js +64 -0
- package/dist/patterns/ExRegular.d.ts +3 -0
- package/dist/patterns/ExRegular.js +64 -0
- package/dist/patterns/FlowerDense.d.ts +3 -0
- package/dist/patterns/FlowerDense.js +58 -0
- package/dist/patterns/FlowerLoose.d.ts +3 -0
- package/dist/patterns/FlowerLoose.js +58 -0
- package/dist/patterns/FlowerRegular.d.ts +3 -0
- package/dist/patterns/FlowerRegular.js +58 -0
- package/dist/patterns/GridDense.d.ts +3 -0
- package/dist/patterns/GridDense.js +57 -0
- package/dist/patterns/GridLoose.d.ts +3 -0
- package/dist/patterns/GridLoose.js +57 -0
- package/dist/patterns/GridRegular.d.ts +3 -0
- package/dist/patterns/GridRegular.js +57 -0
- package/dist/patterns/Herringbone.d.ts +3 -0
- package/dist/patterns/Herringbone.js +75 -0
- package/dist/patterns/RainDense.d.ts +3 -0
- package/dist/patterns/RainDense.js +47 -0
- package/dist/patterns/RainLoose.d.ts +3 -0
- package/dist/patterns/RainLoose.js +47 -0
- package/dist/patterns/RainRegular.d.ts +3 -0
- package/dist/patterns/RainRegular.js +47 -0
- package/dist/patterns/StripeDense.d.ts +3 -0
- package/dist/patterns/StripeDense.js +79 -0
- package/dist/patterns/StripeLoose.d.ts +3 -0
- package/dist/patterns/StripeLoose.js +211 -0
- package/dist/patterns/StripeRegular.d.ts +3 -0
- package/dist/patterns/StripeRegular.js +123 -0
- package/dist/patterns/index.d.ts +28 -0
- package/dist/patterns/index.js +28 -0
- package/dist/props.d.ts +193 -0
- package/dist/props.js +9 -0
- package/dist/svg/CheckerDense.svg +14 -0
- package/dist/svg/CheckerLoose.svg +14 -0
- package/dist/svg/CheckerRegular.svg +14 -0
- package/dist/svg/DiagonalADense.svg +20 -0
- package/dist/svg/DiagonalALoose.svg +44 -0
- package/dist/svg/DiagonalARegular.svg +28 -0
- package/dist/svg/DiagonalBDense.svg +24 -0
- package/dist/svg/DiagonalBLoose.svg +28 -0
- package/dist/svg/DiagonalBRegular.svg +28 -0
- package/dist/svg/DotDense.svg +13 -0
- package/dist/svg/DotLoose.svg +40 -0
- package/dist/svg/DotRegular.svg +13 -0
- package/dist/svg/ExDense.svg +17 -0
- package/dist/svg/ExLoose.svg +17 -0
- package/dist/svg/ExRegular.svg +17 -0
- package/dist/svg/FlowerDense.svg +16 -0
- package/dist/svg/FlowerLoose.svg +16 -0
- package/dist/svg/FlowerRegular.svg +16 -0
- package/dist/svg/GridDense.svg +16 -0
- package/dist/svg/GridLoose.svg +16 -0
- package/dist/svg/GridRegular.svg +16 -0
- package/dist/svg/Herringbone.svg +19 -0
- package/dist/svg/RainDense.svg +14 -0
- package/dist/svg/RainLoose.svg +14 -0
- package/dist/svg/RainRegular.svg +14 -0
- package/dist/svg/StripeDense.svg +20 -0
- package/dist/svg/StripeLoose.svg +44 -0
- package/dist/svg/StripeRegular.svg +28 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +0 -0
- package/dist/usePatternId.d.ts +1 -0
- package/dist/usePatternId.js +10 -0
- package/emotion-plugin.js +46 -0
- package/icon-template.js +28 -0
- package/index-template.js +10 -0
- package/jest.config.js +1 -0
- package/package.json +24 -28
- package/svgr.config.js +29 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<svg>
|
|
2
|
+
<pattern
|
|
3
|
+
id="stripeRegular"
|
|
4
|
+
x="0"
|
|
5
|
+
y="0"
|
|
6
|
+
width="8"
|
|
7
|
+
height="8"
|
|
8
|
+
patternUnits="userSpaceOnUse"
|
|
9
|
+
>
|
|
10
|
+
<rect x="1" width="1" height="1" fill="currentColor" />
|
|
11
|
+
<rect width="1" height="1" fill="currentColor" />
|
|
12
|
+
<rect x="2" width="1" height="1" fill="currentColor" />
|
|
13
|
+
<rect x="3" width="1" height="1" fill="currentColor" />
|
|
14
|
+
<rect x="1" y="4" width="1" height="1" fill="currentColor" />
|
|
15
|
+
<rect y="4" width="1" height="1" fill="currentColor" />
|
|
16
|
+
<rect x="2" y="4" width="1" height="1" fill="currentColor" />
|
|
17
|
+
<rect x="3" y="4" width="1" height="1" fill="currentColor" />
|
|
18
|
+
<rect x="5" width="1" height="1" fill="currentColor" />
|
|
19
|
+
<rect x="4" width="1" height="1" fill="currentColor" />
|
|
20
|
+
<rect x="6" width="1" height="1" fill="currentColor" />
|
|
21
|
+
<rect x="7" width="1" height="1" fill="currentColor" />
|
|
22
|
+
<rect x="5" y="4" width="1" height="1" fill="currentColor" />
|
|
23
|
+
<rect x="4" y="4" width="1" height="1" fill="currentColor" />
|
|
24
|
+
<rect x="6" y="4" width="1" height="1" fill="currentColor" />
|
|
25
|
+
<rect x="7" y="4" width="1" height="1" fill="currentColor" />
|
|
26
|
+
</pattern>
|
|
27
|
+
<rect x="0" y="0" width="100%" height="100%" fill="url(#stripeRegular)" />
|
|
28
|
+
</svg>
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { PatternProps } from './props';
|
package/dist/types.js
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePatternId(id: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
var counter = {};
|
|
3
|
+
export function usePatternId(id) {
|
|
4
|
+
return useMemo(function () {
|
|
5
|
+
var key = id.toLowerCase();
|
|
6
|
+
var idCounter = (counter === null || counter === void 0 ? void 0 : counter[key]) || 0;
|
|
7
|
+
counter[key] = idCounter;
|
|
8
|
+
return "".concat(id, "-pattern-").concat(counter[key] += 1);
|
|
9
|
+
}, [id]);
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const plugin = (api) => {
|
|
2
|
+
const vistor = {
|
|
3
|
+
JSXElement(path) {
|
|
4
|
+
// We only want to find SVG element
|
|
5
|
+
if (path.get('openingElement.name').isJSXIdentifier({ name: 'svg' })) {
|
|
6
|
+
// Update the opening and closing tags to the styled component identifier
|
|
7
|
+
const emotionTag = api.types.jsxIdentifier('Svg');
|
|
8
|
+
path.get('openingElement.name').replaceWith(emotionTag);
|
|
9
|
+
path.get('closingElement.name').replaceWith(emotionTag);
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
JSXAttribute(path) {
|
|
13
|
+
const valuePath = path.get('value');
|
|
14
|
+
const attrName = path.get('name').toString();
|
|
15
|
+
if (attrName === 'id' && valuePath.isStringLiteral()) {
|
|
16
|
+
valuePath.replaceWith(
|
|
17
|
+
api.types.jsxExpressionContainer(
|
|
18
|
+
api.template.ast('patternId').expression
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
attrName === 'fill' &&
|
|
25
|
+
valuePath.isStringLiteral() &&
|
|
26
|
+
valuePath.toString().includes('url')
|
|
27
|
+
) {
|
|
28
|
+
valuePath.replaceWith(
|
|
29
|
+
api.types.jsxExpressionContainer(
|
|
30
|
+
api.template.ast('`url(#${patternId})`').expression
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
visitor: {
|
|
39
|
+
Program(path) {
|
|
40
|
+
path.traverse(vistor);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
module.exports = plugin;
|
package/icon-template.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { startCase } = require('lodash');
|
|
3
|
+
|
|
4
|
+
function iconTemplate(api, opts, { jsx }) {
|
|
5
|
+
const template = api.template.smart({ plugins: ['jsx', 'typescript'] });
|
|
6
|
+
const { componentName, filePath } = opts.state;
|
|
7
|
+
const exportName = componentName.replace('Svg', '');
|
|
8
|
+
const title = startCase(path.basename(filePath, '.svg'));
|
|
9
|
+
|
|
10
|
+
return template.ast`
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { Svg, PatternProps } from '../props';
|
|
13
|
+
import { usePatternId } from '../usePatternId';
|
|
14
|
+
|
|
15
|
+
export const ${exportName} = React.forwardRef<SVGSVGElement, PatternProps>(({
|
|
16
|
+
title = "${title}",
|
|
17
|
+
titleId,
|
|
18
|
+
...props
|
|
19
|
+
},
|
|
20
|
+
svgRef
|
|
21
|
+
) => {
|
|
22
|
+
const patternId = usePatternId('${exportName}');
|
|
23
|
+
|
|
24
|
+
return ${jsx};
|
|
25
|
+
});
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
module.exports = iconTemplate;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
function indexTemplate(files) {
|
|
4
|
+
const exportEntries = files.map((file) => {
|
|
5
|
+
const basename = path.basename(file, path.extname(file));
|
|
6
|
+
return `export * from './${basename}';`;
|
|
7
|
+
});
|
|
8
|
+
return exportEntries.join('\n');
|
|
9
|
+
}
|
|
10
|
+
module.exports = indexTemplate;
|
package/jest.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../jest.config.base')('gamut-patterns');
|
package/package.json
CHANGED
|
@@ -1,52 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
3
3
|
"bugs": {
|
|
4
|
-
"url": "https://github.com/Codecademy/
|
|
4
|
+
"url": "https://github.com/Codecademy/gamut/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@codecademy/gamut": "
|
|
8
|
-
"@codecademy/
|
|
9
|
-
"@codecademy/gamut-system": "^0.7.0",
|
|
7
|
+
"@codecademy/gamut-styles": "13.0.0-alpha.d04966.0",
|
|
8
|
+
"@codecademy/variance": "1.0.0-alpha.d04966.0",
|
|
10
9
|
"classnames": "^2.2.5"
|
|
11
10
|
},
|
|
12
11
|
"description": "Pattern library for Codecademy",
|
|
13
|
-
"homepage": "https://github.com/Codecademy/
|
|
12
|
+
"homepage": "https://github.com/Codecademy/gamut#readme",
|
|
14
13
|
"name": "@codecademy/gamut-patterns",
|
|
15
|
-
"module": "
|
|
16
|
-
"
|
|
14
|
+
"module": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@emotion/react": "^11.
|
|
20
|
-
"@emotion/styled": "^11.
|
|
21
|
-
"react": ">=
|
|
22
|
-
"react-dom": ">=
|
|
19
|
+
"@emotion/react": "^11.4.0",
|
|
20
|
+
"@emotion/styled": "^11.3.0",
|
|
21
|
+
"react": ">=17.0.2",
|
|
22
|
+
"react-dom": ">=17.0.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@svgr/cli": "5.5.0",
|
|
26
|
+
"lodash": "^4.17.5",
|
|
27
|
+
"svgo": "^1.3.2"
|
|
23
28
|
},
|
|
24
29
|
"publishConfig": {
|
|
25
30
|
"access": "public"
|
|
26
31
|
},
|
|
27
32
|
"repository": {
|
|
28
33
|
"type": "git",
|
|
29
|
-
"url": "git+ssh://git@github.com/Codecademy/
|
|
34
|
+
"url": "git+ssh://git@github.com/Codecademy/gamut.git"
|
|
30
35
|
},
|
|
31
36
|
"scripts": {
|
|
32
37
|
"verify": "tsc --noEmit",
|
|
33
|
-
"
|
|
34
|
-
"build:
|
|
38
|
+
"format": "svgo -f ./src/svg --pretty --config=.svgo.yml",
|
|
39
|
+
"build:icons": "rm -rf ./src/patterns && svgr --out-dir ./src/patterns --ext 'tsx' ./src/svg",
|
|
35
40
|
"build:types": "tsc --emitDeclarationOnly",
|
|
36
|
-
"build": "
|
|
41
|
+
"build:compile": "babel ./src --out-dir ./dist --copy-files --extensions \".ts,.tsx\"",
|
|
42
|
+
"build": "yarn build:icons && yarn build:compile && yarn build:types",
|
|
37
43
|
"lernaBuildTask": "yarn build"
|
|
38
44
|
},
|
|
39
|
-
"sideEffects":
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
],
|
|
43
|
-
"version": "1.0.0-alpha.b00dca.0",
|
|
44
|
-
"directories": {
|
|
45
|
-
"lib": "lib",
|
|
46
|
-
"test": "__tests__"
|
|
47
|
-
},
|
|
48
|
-
"files": [
|
|
49
|
-
"lib"
|
|
50
|
-
],
|
|
51
|
-
"gitHead": "31260f6461cfb40fb1b2a7928ae95278817e5e77"
|
|
45
|
+
"sideEffects": false,
|
|
46
|
+
"version": "1.0.0-alpha.d04966.0",
|
|
47
|
+
"gitHead": "8ddee0b47bb724237b970fff8f68bfef6962fa79"
|
|
52
48
|
}
|
package/svgr.config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const emotionPlugin = require('./emotion-plugin');
|
|
2
|
+
const template = require('./icon-template');
|
|
3
|
+
const indexTemplate = require('./index-template');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
dimensions: false,
|
|
7
|
+
titleProp: true,
|
|
8
|
+
ref: true,
|
|
9
|
+
svgProps: {
|
|
10
|
+
fill: 'currentColor',
|
|
11
|
+
role: 'img',
|
|
12
|
+
'aria-hidden': 'true',
|
|
13
|
+
},
|
|
14
|
+
prettierConfig: {
|
|
15
|
+
parser: 'typescript',
|
|
16
|
+
},
|
|
17
|
+
replaceAttrValues: {
|
|
18
|
+
'#000': 'currentColor',
|
|
19
|
+
'#111': 'currentColor',
|
|
20
|
+
'#444': 'currentColor',
|
|
21
|
+
},
|
|
22
|
+
jsx: {
|
|
23
|
+
babelConfig: {
|
|
24
|
+
plugins: [emotionPlugin],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
indexTemplate,
|
|
28
|
+
template,
|
|
29
|
+
};
|