@madgex/design-system 1.24.2 → 1.26.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/.vscode/launch.json +1 -1
- package/__tests__/unit/tasks/css.spec.js +5 -0
- package/__tests__/unit/tasks/jsbundle.spec.js +5 -0
- package/__tests__/unit/tasks/svgsprite.spec.js +5 -0
- package/__tests__/unit/tasks/tokens.spec.js +5 -0
- package/coverage/cobertura-coverage.xml +3 -2
- package/coverage/components/accordion/accordion.js.html +1 -1
- package/coverage/components/accordion/index.html +1 -1
- package/coverage/components/tabs/index.html +1 -1
- package/coverage/components/tabs/tabs.js.html +1 -1
- package/coverage/index.html +7 -7
- package/coverage/js/common.js.html +1 -1
- package/coverage/js/index-polyfills.js.html +1 -1
- package/coverage/js/index.html +1 -1
- package/coverage/js/index.js.html +1 -1
- package/coverage/js/polyfills/closest.js.html +1 -1
- package/coverage/js/polyfills/index.html +1 -1
- package/coverage/tokens/_config.js.html +17 -11
- package/coverage/tokens/index.html +5 -5
- package/dist/_tokens/css/_tokens.css +1 -1
- package/dist/_tokens/js/_tokens-module.js +1 -1
- package/dist/_tokens/scss/_tokens.scss +1 -1
- package/dist/assets/icons.svg +1 -1
- package/dist/css/index.css +1 -1
- package/dist/js/index.js +2 -2
- package/docs/tokens/spacing.njk +2 -2
- package/fractal.js +2 -2
- package/gulpfile.js +11 -11
- package/hook.js +63 -0
- package/package.json +32 -34
- package/src/components/pagination/README.md +20 -0
- package/src/components/pagination/_macro.njk +3 -0
- package/src/components/pagination/_template.njk +49 -0
- package/src/components/pagination/pagination.config.js +48 -0
- package/src/components/pagination/pagination.njk +17 -0
- package/src/components/pagination/pagination.scss +35 -0
- package/src/scss/components/__index.scss +2 -1
- package/src/scss/helpers/__index.scss +1 -1
- package/src/scss/index.scss +1 -1
- package/src/tokens/_config.js +8 -6
- package/src/tokens/overrides/override.json +1 -0
- package/src/tokens/size.json +1 -1
- package/tasks/css.js +97 -0
- package/{gulp-tasks → tasks}/fractal.js +6 -4
- package/tasks/js-bundle.js +44 -0
- package/tasks/svgsprite.js +69 -0
- package/tasks/tokens.js +34 -0
- package/gulp-tasks/css.js +0 -22
- package/gulp-tasks/js-bundle.js +0 -31
- package/gulp-tasks/svgsprite.js +0 -57
- package/gulp-tasks/tokens.js +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madgex/design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "rimraf dist public tokens/build",
|
|
6
6
|
"commit": "commit",
|
|
@@ -21,60 +21,58 @@
|
|
|
21
21
|
"url": "https://github.com/madgex/madgex-design-system"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"css-loader": "^3.2.0",
|
|
25
|
+
"mini-css-extract-plugin": "^0.8.0",
|
|
26
|
+
"ncp": "^2.0.0",
|
|
24
27
|
"node-sass": "^4.12.0",
|
|
25
|
-
"
|
|
28
|
+
"postcss": "^7.0.18",
|
|
29
|
+
"postcss-cli": "^6.1.3",
|
|
30
|
+
"postcss-loader": "^3.0.0",
|
|
31
|
+
"sass-loader": "^7.3.1",
|
|
32
|
+
"style-dictionary": "^2.8.2",
|
|
33
|
+
"style-loader": "^0.23.1",
|
|
26
34
|
"svgxuse": "^1.2.6"
|
|
27
35
|
},
|
|
28
36
|
"devDependencies": {
|
|
29
|
-
"@babel/core": "^7.
|
|
30
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
31
|
-
"@babel/preset-env": "^7.
|
|
32
|
-
"@babel/runtime": "^7.
|
|
33
|
-
"@commitlint/cli": "^8.
|
|
34
|
-
"@commitlint/config-conventional": "^8.
|
|
35
|
-
"@commitlint/prompt-cli": "^8.
|
|
37
|
+
"@babel/core": "^7.6.4",
|
|
38
|
+
"@babel/plugin-transform-runtime": "^7.6.2",
|
|
39
|
+
"@babel/preset-env": "^7.6.3",
|
|
40
|
+
"@babel/runtime": "^7.6.3",
|
|
41
|
+
"@commitlint/cli": "^8.2.0",
|
|
42
|
+
"@commitlint/config-conventional": "^8.2.0",
|
|
43
|
+
"@commitlint/prompt-cli": "^8.2.0",
|
|
36
44
|
"@frctl/fractal": "^1.2.0",
|
|
37
45
|
"@frctl/mandelbrot": "^1.2.1",
|
|
38
46
|
"@frctl/nunjucks": "^2.0.1",
|
|
39
47
|
"@madgex/eslint-config-madgex": "^1.2.0",
|
|
40
|
-
"autoprefixer": "^9.6.
|
|
48
|
+
"autoprefixer": "^9.6.5",
|
|
41
49
|
"babel-jest": "^24.9.0",
|
|
42
50
|
"babel-loader": "^8.0.6",
|
|
43
51
|
"commitizen": "^3.1.2",
|
|
44
|
-
"concurrently": "^4.1.
|
|
45
|
-
"core-js": "^3.
|
|
46
|
-
"css-loader": "^3.1.0",
|
|
52
|
+
"concurrently": "^4.1.2",
|
|
53
|
+
"core-js": "^3.3.2",
|
|
47
54
|
"cssnano": "^4.1.10",
|
|
48
55
|
"cz-conventional-changelog": "^2.1.0",
|
|
49
|
-
"del": "^5.
|
|
50
|
-
"file-loader": "^4.
|
|
56
|
+
"del": "^5.1.0",
|
|
57
|
+
"file-loader": "^4.2.0",
|
|
51
58
|
"flat": "^4.1.0",
|
|
52
|
-
"glob": "^7.1.4",
|
|
53
59
|
"gulp": "^4.0.2",
|
|
54
|
-
"
|
|
55
|
-
"gulp-rename": "^1.4.0",
|
|
56
|
-
"gulp-sass": "^4.0.2",
|
|
57
|
-
"gulp-svgmin": "^2.2.0",
|
|
58
|
-
"gulp-svgstore": "^7.0.1",
|
|
59
|
-
"gulp-tap": "^1.0.1",
|
|
60
|
-
"husky": "^3.0.2",
|
|
60
|
+
"husky": "^3.0.9",
|
|
61
61
|
"jest": "^24.9.0",
|
|
62
62
|
"jsdom": "^15.2.0",
|
|
63
|
-
"
|
|
63
|
+
"link-module-alias": "^1.2.0",
|
|
64
|
+
"lint-staged": "^9.4.2",
|
|
64
65
|
"mini-css-extract-plugin": "^0.8.0",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"rimraf": "^2.6.3",
|
|
69
|
-
"sass-loader": "^7.1.0",
|
|
70
|
-
"semantic-release": "^15.13.19",
|
|
71
|
-
"style-loader": "^0.23.1",
|
|
66
|
+
"node-sass": "^4.12.0",
|
|
67
|
+
"rimraf": "^2.7.1",
|
|
68
|
+
"semantic-release": "^15.13.24",
|
|
72
69
|
"svg-sprite-loader": "^4.1.6",
|
|
73
70
|
"svgo": "^1.3.0",
|
|
74
71
|
"svgo-loader": "^2.2.1",
|
|
75
|
-
"
|
|
76
|
-
"webpack
|
|
77
|
-
"webpack-
|
|
72
|
+
"svgstore": "^3.0.0-2",
|
|
73
|
+
"webpack": "^4.41.2",
|
|
74
|
+
"webpack-cli": "^3.3.9",
|
|
75
|
+
"webpack-dev-server": "^3.8.2",
|
|
78
76
|
"webpack-stream": "^5.2.1"
|
|
79
77
|
},
|
|
80
78
|
"config": {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
## Parameters
|
|
2
|
+
|
|
3
|
+
- `name`: name of the component, used for accessibility purpose, should be descriptive (i.e. lister pagination)
|
|
4
|
+
- `classes`: add extra CSS classes to the component
|
|
5
|
+
- `hideIcons`: hide caret icons
|
|
6
|
+
- `prevLabel`: label of the previous link
|
|
7
|
+
- `prevUrl`: url of the previous link
|
|
8
|
+
- `prevVisHiddenLabel`: hidden label for accessibility purpose
|
|
9
|
+
- `prevExtraLabel`: extra label of the previous link (i.e. title of the page)
|
|
10
|
+
- `nextLabel`: label of the next link
|
|
11
|
+
- `nextUrl`: url of the next link
|
|
12
|
+
- `nextVisHiddenLabel`: hidden label for accessibility purpose
|
|
13
|
+
- `nextExtraLabel`: extra label of the next link (i.e. title of the page)
|
|
14
|
+
- `backToLabel`: label of the "back to" link
|
|
15
|
+
- `backToUrl`: url of the "back to" link
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Accessibility
|
|
19
|
+
|
|
20
|
+
use the hidden labels to give more information about the links, i.e. adding "job" to the Previous link, so that the screen reader will read: "Previous job"
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{% from "../icons/_macro.njk" import MdsIcon %}
|
|
2
|
+
|
|
3
|
+
<nav aria-label="{{ params.name }}">
|
|
4
|
+
<ul class="mds-pagination mds-text-align-right mds-clearfix{% if params.classes %} {{params.classes}}{% endif %}">
|
|
5
|
+
{% if params.backToLabel and params.backToUrl -%}
|
|
6
|
+
<li class="mds-float-left">
|
|
7
|
+
<a href="{{ params.backToUrl }}" class="mds-pagination__link mds-pagination__link--back" aria-label="{{- params.backToLabel -}}">
|
|
8
|
+
{% if not params.hideIcons -%}
|
|
9
|
+
{{ MdsIcon({
|
|
10
|
+
iconName: 'chevron-left',
|
|
11
|
+
classes: 'mds-icon--before'
|
|
12
|
+
}) -}}
|
|
13
|
+
{%- endif %}
|
|
14
|
+
{{ params.backToLabel }}
|
|
15
|
+
</a>
|
|
16
|
+
</li>
|
|
17
|
+
{%- endif %}
|
|
18
|
+
{% if params.prevLabel and params.prevUrl -%}
|
|
19
|
+
<li class="mds-float-left">
|
|
20
|
+
<a href="{{ params.prevUrl }}" class="mds-pagination__link mds-pagination__link--background" aria-label="{{ params.prevLabel }} {{ params.prevVisHiddenLabel }} - {{ params.prevExtraLabel | truncate(40, false) }}">
|
|
21
|
+
{% if not params.hideIcons -%}
|
|
22
|
+
{{ MdsIcon({
|
|
23
|
+
iconName: 'chevron-left',
|
|
24
|
+
classes: 'mds-icon--before'
|
|
25
|
+
}) }}
|
|
26
|
+
{%- endif -%}
|
|
27
|
+
<span>{{- params.prevLabel -}}</span>
|
|
28
|
+
{%- if params.prevVisHiddenLabel -%}<span class="mds-visually-hidden">{{- params.prevVisHiddenLabel -}}</span>{%- endif -%}
|
|
29
|
+
{%- if params.prevExtraLabel -%}<strong class="mds-pagination__extra-label mds-padding-left-b3">{{ params.prevExtraLabel | truncate(40, false) }}</strong>{%- endif %}
|
|
30
|
+
</a>
|
|
31
|
+
</li>
|
|
32
|
+
{%- endif %}
|
|
33
|
+
{% if params.nextLabel and params.nextUrl -%}
|
|
34
|
+
<li>
|
|
35
|
+
<a href="{{ params.nextUrl }}" class="mds-pagination__link mds-pagination__link--background" aria-label="{{ params.nextLabel }} {{ params.nextVisHiddenLabel }} - {{ params.nextExtraLabel | truncate(40, false) }}">
|
|
36
|
+
{%- if params.nextExtraLabel -%}<strong class="mds-pagination__extra-label mds-margin-right-b3">{{ params.nextExtraLabel | truncate(40, false) }}</strong>{%- endif -%}
|
|
37
|
+
<span>{{- params.nextLabel -}}</span>
|
|
38
|
+
{%- if params.nextVisHiddenLabel -%}<span class="mds-visually-hidden">{{- params.nextVisHiddenLabel -}}</span>{%- endif -%}
|
|
39
|
+
{% if not params.hideIcons -%}
|
|
40
|
+
{{ MdsIcon({
|
|
41
|
+
iconName: 'chevron-right',
|
|
42
|
+
classes: 'mds-icon--after'
|
|
43
|
+
}) }}
|
|
44
|
+
{%- endif %}
|
|
45
|
+
</a>
|
|
46
|
+
</li>
|
|
47
|
+
{%- endif %}
|
|
48
|
+
</ul>
|
|
49
|
+
</nav>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
title: 'Pagination',
|
|
3
|
+
label: 'Pagination',
|
|
4
|
+
context: {
|
|
5
|
+
name: 'Job details pagination',
|
|
6
|
+
nextLabel: 'Next',
|
|
7
|
+
nextUrl: '/next-page',
|
|
8
|
+
},
|
|
9
|
+
variants: [
|
|
10
|
+
{
|
|
11
|
+
name: 'Job Detail',
|
|
12
|
+
context: {
|
|
13
|
+
prevLabel: 'Previous',
|
|
14
|
+
prevUrl: '/prev-page',
|
|
15
|
+
nextLabel: 'Next',
|
|
16
|
+
nextUrl: '/next-page',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Job Detail',
|
|
21
|
+
context: {
|
|
22
|
+
classes: 'mds-font-long-primer',
|
|
23
|
+
nextLabel: 'Next',
|
|
24
|
+
nextUrl: '/next-page',
|
|
25
|
+
nextVisHiddenLabel: 'Job',
|
|
26
|
+
nextExtraLabel: 'Customer Service, Special-Agent Assistant Part-Time',
|
|
27
|
+
backToLabel: 'Results',
|
|
28
|
+
backToUrl: '/results/',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Job Detail',
|
|
33
|
+
context: {
|
|
34
|
+
classes: 'mds-font-long-primer',
|
|
35
|
+
prevLabel: 'Previous',
|
|
36
|
+
prevUrl: '/prev-page',
|
|
37
|
+
prevVisHiddenLabel: 'Job',
|
|
38
|
+
prevExtraLabel: 'Part Time Sales Assistant',
|
|
39
|
+
nextLabel: 'Next',
|
|
40
|
+
nextUrl: '/next-page',
|
|
41
|
+
nextVisHiddenLabel: 'Job',
|
|
42
|
+
nextExtraLabel: 'Customer Service, Special-Agent Assistant Part-Time',
|
|
43
|
+
backToLabel: 'Results',
|
|
44
|
+
backToUrl: '/results/',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{% from "./pagination/_macro.njk" import MdsPagination %}
|
|
2
|
+
|
|
3
|
+
{{ MdsPagination({
|
|
4
|
+
name: name,
|
|
5
|
+
classes: classes,
|
|
6
|
+
hideIcons: hideIcons,
|
|
7
|
+
prevLabel: prevLabel,
|
|
8
|
+
prevUrl: prevUrl,
|
|
9
|
+
prevVisHiddenLabel: prevVisHiddenLabel,
|
|
10
|
+
prevExtraLabel: prevExtraLabel,
|
|
11
|
+
nextLabel: nextLabel,
|
|
12
|
+
nextUrl: nextUrl,
|
|
13
|
+
nextVisHiddenLabel: nextVisHiddenLabel,
|
|
14
|
+
nextExtraLabel: nextExtraLabel,
|
|
15
|
+
backToLabel: backToLabel,
|
|
16
|
+
backToUrl: backToUrl
|
|
17
|
+
}) }}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.mds-pagination {
|
|
2
|
+
text-align: right;
|
|
3
|
+
width: 100%;
|
|
4
|
+
@extend .mds-surface;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.mds-pagination__link{
|
|
8
|
+
display: inline-block;
|
|
9
|
+
padding: $mds-size-baseline * 3;
|
|
10
|
+
|
|
11
|
+
&--back{
|
|
12
|
+
@include mq($from: $mds-size-breakpoint-sm) {
|
|
13
|
+
border-right: $mds-size-border-width solid $mds-color-border;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&--background{
|
|
18
|
+
&:hover,
|
|
19
|
+
&:focus {
|
|
20
|
+
background-color: $mds-color-neutral-lightest;
|
|
21
|
+
& > span,
|
|
22
|
+
& > strong{
|
|
23
|
+
text-decoration: underline;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.mds-pagination__extra-label{
|
|
30
|
+
display: none;
|
|
31
|
+
|
|
32
|
+
@include mq($from: $mds-size-breakpoint-lg) {
|
|
33
|
+
display: inline;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
@import '../../components/tabs/tabs';
|
|
6
6
|
@import '../../components/input/input';
|
|
7
7
|
@import '../../components/textarea/textarea';
|
|
8
|
-
@import '../../components/accordion/accordion';
|
|
8
|
+
@import '../../components/accordion/accordion';
|
|
9
|
+
@import '../../components/pagination/pagination';
|
package/src/scss/index.scss
CHANGED
package/src/tokens/_config.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
1
3
|
const config = {
|
|
2
|
-
source: ['
|
|
4
|
+
source: [path.resolve(__dirname, '../tokens/*.json'), path.resolve(__dirname, '../tokens/overrides/override.json')],
|
|
3
5
|
platforms: {
|
|
4
6
|
'css-variables': {
|
|
5
7
|
// transformGroup: 'css',
|
|
6
8
|
transforms: ['attribute/cti', 'name/cti/kebab', 'time/seconds', 'content/icon', 'color/css'],
|
|
7
|
-
buildPath: 'dist/_tokens/css/'
|
|
9
|
+
buildPath: `${path.resolve(__dirname, '../../dist/_tokens/css/')}/`,
|
|
8
10
|
prefix: 'mds',
|
|
9
11
|
files: [
|
|
10
12
|
{
|
|
@@ -15,9 +17,9 @@ const config = {
|
|
|
15
17
|
},
|
|
16
18
|
'scss-variables': {
|
|
17
19
|
// transformGroup: 'web',
|
|
18
|
-
// transforms: ['size/px']
|
|
20
|
+
// transforms: ['size/px']
|
|
19
21
|
transforms: ['attribute/cti', 'name/cti/kebab', 'color/css', 'color/scssColorFunctions'],
|
|
20
|
-
buildPath: 'dist/_tokens/scss/'
|
|
22
|
+
buildPath: `${path.resolve(__dirname, '../../dist/_tokens/scss/')}/`,
|
|
21
23
|
prefix: 'mds',
|
|
22
24
|
files: [
|
|
23
25
|
{
|
|
@@ -29,7 +31,7 @@ const config = {
|
|
|
29
31
|
},
|
|
30
32
|
sketch: {
|
|
31
33
|
transformGroup: 'web',
|
|
32
|
-
buildPath: 'dist/_tokens/sketch/'
|
|
34
|
+
buildPath: `${path.resolve(__dirname, '../../dist/_tokens/sketch/')}/`,
|
|
33
35
|
prefix: 'mds',
|
|
34
36
|
files: [
|
|
35
37
|
{
|
|
@@ -66,7 +68,7 @@ const config = {
|
|
|
66
68
|
// },
|
|
67
69
|
'js-module': {
|
|
68
70
|
transformGroup: 'js',
|
|
69
|
-
buildPath: 'dist/_tokens/js/'
|
|
71
|
+
buildPath: `${path.resolve(__dirname, '../../dist/_tokens/js/')}/`,
|
|
70
72
|
prefix: 'mds',
|
|
71
73
|
files: [
|
|
72
74
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/src/tokens/size.json
CHANGED
package/tasks/css.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const del = require('del');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const autoprefixer = require('autoprefixer');
|
|
5
|
+
const cssnano = require('cssnano');
|
|
6
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
7
|
+
|
|
8
|
+
async function runWebpack(localSrcFilePath) {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
webpack(
|
|
11
|
+
{
|
|
12
|
+
entry: `${localSrcFilePath}/index.scss`,
|
|
13
|
+
output: {
|
|
14
|
+
path: path.resolve(__dirname, '../dist/css'),
|
|
15
|
+
},
|
|
16
|
+
plugins: [
|
|
17
|
+
new MiniCssExtractPlugin({
|
|
18
|
+
filename: `index.css`,
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
module: {
|
|
22
|
+
rules: [
|
|
23
|
+
{
|
|
24
|
+
test: /\.(sa|sc|c)ss$/,
|
|
25
|
+
use: [
|
|
26
|
+
{
|
|
27
|
+
loader: MiniCssExtractPlugin.loader,
|
|
28
|
+
options: {
|
|
29
|
+
publicPath: path.resolve(__dirname, '../dist/css'),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
loader: 'css-loader',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
loader: 'postcss-loader',
|
|
37
|
+
options: {
|
|
38
|
+
plugins: [autoprefixer(), cssnano()],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
loader: 'sass-loader',
|
|
43
|
+
options: {
|
|
44
|
+
outputStyle: 'compressed',
|
|
45
|
+
precision: 10,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
(err, stats) => {
|
|
54
|
+
const info = stats.toJson();
|
|
55
|
+
if (err || stats.hasErrors()) {
|
|
56
|
+
if (err) {
|
|
57
|
+
console.error(err);
|
|
58
|
+
reject(err);
|
|
59
|
+
}
|
|
60
|
+
if (stats.hasErrors()) {
|
|
61
|
+
console.error(info.errors);
|
|
62
|
+
reject(err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
resolve('webpack compiled');
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function css() {
|
|
71
|
+
const localSrcFilePath = path.resolve(__dirname, '../src/scss');
|
|
72
|
+
await runWebpack(localSrcFilePath);
|
|
73
|
+
await del(path.resolve(__dirname, '../dist/css/main.js'), {
|
|
74
|
+
force: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// sass(src, dist); // outputStyle: 'compressed', precision: 10,
|
|
79
|
+
// autoprefixer();
|
|
80
|
+
// rename('index.css');
|
|
81
|
+
// gulp.dest('dist/css');
|
|
82
|
+
|
|
83
|
+
// return gulp
|
|
84
|
+
// .src('src/scss/index.scss')
|
|
85
|
+
// .pipe(
|
|
86
|
+
// sass.sync({
|
|
87
|
+
// outputStyle: 'compressed',
|
|
88
|
+
// precision: 10,
|
|
89
|
+
// includePaths: ['./node_modules'],
|
|
90
|
+
// })
|
|
91
|
+
// )
|
|
92
|
+
// .on('error', sass.logError)
|
|
93
|
+
// .pipe(autoprefixer())
|
|
94
|
+
// .pipe(rename('index.css'))
|
|
95
|
+
// .pipe(gulp.dest('dist/css'));
|
|
96
|
+
|
|
97
|
+
exports.css = css;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* An example of a Gulp task that starts a Fractal development server.
|
|
3
3
|
*/
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const fractalInitFile = path.resolve(__dirname, '../fractal.js');
|
|
4
7
|
|
|
5
8
|
function fractalStart() {
|
|
6
|
-
const fractal = require(
|
|
9
|
+
const fractal = require(fractalInitFile); // eslint-disable-line
|
|
7
10
|
// import the Fractal instance configured in the fractal.js file
|
|
8
11
|
const logger = fractal.cli.console; // make use of Fractal's console object for logging
|
|
9
12
|
const server = fractal.web.server({
|
|
@@ -16,9 +19,8 @@ function fractalStart() {
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
function fractalBuild() {
|
|
19
|
-
delete require.cache[require.resolve(
|
|
20
|
-
|
|
21
|
-
const fractal = require('../fractal.js');
|
|
22
|
+
delete require.cache[require.resolve(fractalInitFile)]; // eslint-disable-line
|
|
23
|
+
const fractal = require(fractalInitFile); // eslint-disable-line
|
|
22
24
|
// import the Fractal instance configured in the fractal.js file
|
|
23
25
|
const logger = fractal.cli.console; // make use of Fractal's console object for logging
|
|
24
26
|
const builder = fractal.web.builder();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
|
|
4
|
+
async function runWebpack() {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
webpack(
|
|
7
|
+
{
|
|
8
|
+
entry: [path.resolve(__dirname, '../src/js/index.js'), path.resolve(__dirname, '../src/js/index-polyfills.js')],
|
|
9
|
+
output: {
|
|
10
|
+
filename: 'index.js',
|
|
11
|
+
path: path.resolve(__dirname, '../dist/js'),
|
|
12
|
+
},
|
|
13
|
+
module: {
|
|
14
|
+
rules: [
|
|
15
|
+
{
|
|
16
|
+
test: /\.js$/,
|
|
17
|
+
exclude: /node_modules/,
|
|
18
|
+
loader: 'babel-loader',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
(err, stats) => {
|
|
24
|
+
const info = stats.toJson();
|
|
25
|
+
if (err || stats.hasErrors()) {
|
|
26
|
+
if (err) {
|
|
27
|
+
console.error(err);
|
|
28
|
+
}
|
|
29
|
+
if (stats.hasErrors()) {
|
|
30
|
+
console.error(info.errors);
|
|
31
|
+
}
|
|
32
|
+
reject(err);
|
|
33
|
+
}
|
|
34
|
+
resolve('Webpack has compiled');
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function jsbundle() {
|
|
41
|
+
await runWebpack();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.jsbundle = jsbundle;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable promise/no-promise-in-callback: 0; */
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const SVGO = require('svgo');
|
|
6
|
+
const svgstore = require('svgstore');
|
|
7
|
+
|
|
8
|
+
const filepath = path.resolve(__dirname, '../src/icons/');
|
|
9
|
+
const prefix = path.basename(filepath, path.extname(filepath));
|
|
10
|
+
const svgoOptions = new SVGO({
|
|
11
|
+
plugins: [
|
|
12
|
+
{
|
|
13
|
+
cleanupIDs: {
|
|
14
|
+
prefix: `${prefix}-`,
|
|
15
|
+
minify: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{ removeDoctype: true },
|
|
19
|
+
{ removeComments: true },
|
|
20
|
+
{ removeTitle: true },
|
|
21
|
+
{ removeDesc: true },
|
|
22
|
+
{ removeUselessDefs: true },
|
|
23
|
+
{ removeEditorsNSData: true },
|
|
24
|
+
{ cleanupAttrs: true },
|
|
25
|
+
{ cleanupNumericValues: true },
|
|
26
|
+
{ removeViewBox: false },
|
|
27
|
+
{ removeDimensions: true },
|
|
28
|
+
{
|
|
29
|
+
removeAttrs: {
|
|
30
|
+
attrs: 'fill',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
let files = [];
|
|
37
|
+
const icons = [];
|
|
38
|
+
const sprites = svgstore();
|
|
39
|
+
|
|
40
|
+
async function createSvgStack() {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
files = fs.readdirSync(filepath);
|
|
43
|
+
files.map((file) => {
|
|
44
|
+
svgoOptions
|
|
45
|
+
.optimize(fs.readFileSync(`${path.resolve(__dirname, filepath)}/${file}`, { encoding: 'utf8' }), {
|
|
46
|
+
path: `${path.resolve(__dirname, filepath)}\\${file}`,
|
|
47
|
+
})
|
|
48
|
+
.then((icon) => {
|
|
49
|
+
const fileName = path.parse(file).name;
|
|
50
|
+
sprites.add(fileName, icon.data);
|
|
51
|
+
return fs.mkdir(path.resolve(__dirname, '../dist/assets'), { recursive: true }, async () => {
|
|
52
|
+
icons.push({ name: fileName });
|
|
53
|
+
fs.writeFileSync(`${path.resolve(__dirname, '../dist/assets')}/icons.svg`, sprites);
|
|
54
|
+
fs.writeFileSync(`${path.resolve(__dirname, '../dist/assets')}/icons.json`, JSON.stringify(icons));
|
|
55
|
+
});
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
reject(err);
|
|
59
|
+
});
|
|
60
|
+
resolve('SVG Stack compiled');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function svgsprite() {
|
|
66
|
+
await createSvgStack();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
exports.svgsprite = svgsprite;
|
package/tasks/tokens.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
let StyleDictionary;
|
|
4
|
+
|
|
5
|
+
function registerTransforms() {
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
StyleDictionary.registerTransform({
|
|
8
|
+
name: 'color/scssColorFunctions',
|
|
9
|
+
type: 'value',
|
|
10
|
+
matcher(prop) {
|
|
11
|
+
return prop.attributes.category === 'color' && prop.scssColorFunction;
|
|
12
|
+
},
|
|
13
|
+
transformer(prop) {
|
|
14
|
+
return prop.scssColorFunction;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
resolve('Transform registered');
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function tokens() {
|
|
22
|
+
// Calling this ooutside of the tokens functions stores the extend in memory
|
|
23
|
+
// meaning external hooks cannot use it for programatic overrides
|
|
24
|
+
|
|
25
|
+
StyleDictionary = require('style-dictionary').extend(path.resolve(__dirname, '../src/tokens/_config'));
|
|
26
|
+
try {
|
|
27
|
+
await registerTransforms();
|
|
28
|
+
await StyleDictionary.buildAllPlatforms();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.tokens = tokens;
|
package/gulp-tasks/css.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const gulp = require('gulp');
|
|
2
|
-
const sass = require('gulp-sass');
|
|
3
|
-
const rename = require('gulp-rename');
|
|
4
|
-
const autoprefixer = require('gulp-autoprefixer');
|
|
5
|
-
|
|
6
|
-
function css() {
|
|
7
|
-
return gulp
|
|
8
|
-
.src('src/scss/index.scss')
|
|
9
|
-
.pipe(
|
|
10
|
-
sass.sync({
|
|
11
|
-
outputStyle: 'compressed',
|
|
12
|
-
precision: 10,
|
|
13
|
-
includePaths: ['./node_modules'],
|
|
14
|
-
})
|
|
15
|
-
)
|
|
16
|
-
.on('error', sass.logError)
|
|
17
|
-
.pipe(autoprefixer())
|
|
18
|
-
.pipe(rename('index.css'))
|
|
19
|
-
.pipe(gulp.dest('dist/css'));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.css = css;
|