@madgex/design-system 1.0.1
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/.env-example +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +6 -0
- package/.prettierignore +3 -0
- package/.prettierrc +7 -0
- package/.vscode/launch.json +19 -0
- package/README.md +112 -0
- package/babel.config.js +12 -0
- package/commitlint.config.js +1 -0
- package/delivery/jenkinsfile +100 -0
- package/docs/01-index.njk +11 -0
- package/docs/tokens/colour.njk +43 -0
- package/docs/tokens/spacing.njk +5 -0
- package/fractal-theme/assets/css/styles.css +41 -0
- package/fractal.js +80 -0
- package/gulpfile.js +30 -0
- package/package.json +56 -0
- package/src/components/Button/_macro.njk +3 -0
- package/src/components/Button/_template.njk +35 -0
- package/src/components/Button/button.config.js +22 -0
- package/src/components/Button/button.njk +7 -0
- package/src/components/Button/button.scss +36 -0
- package/src/components/_preview.njk +16 -0
- package/src/core/functions/__index.scss +1 -0
- package/src/core/functions/_color.scss +0 -0
- package/src/core/helpers/__index.scss +11 -0
- package/src/core/helpers/_media-queries.scss +21 -0
- package/src/core/index.scss +31 -0
- package/src/core/utilities/__index.scss +3 -0
- package/src/core/utilities/_clearfix.scss +7 -0
- package/src/core/utilities/_mixins.scss +13 -0
- package/src/core/utilities/_visually-hidden.scss +20 -0
- package/src/core/vendor/_sass-mq.scss +360 -0
- package/src/patterns/form/form.njk +2 -0
- package/tasks/css.js +18 -0
- package/tasks/fractal.js +29 -0
- package/tasks/tokens.js +9 -0
- package/tokens/_config.js +159 -0
- package/tokens/color.json +24 -0
- package/tokens/font.json +9 -0
- package/tokens/size.json +51 -0
package/.env-example
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GH_TOKEN=1234567890
|
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "GulpTester",
|
|
9
|
+
"type": "node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
|
|
12
|
+
"stopOnEntry": false,
|
|
13
|
+
"args": [],
|
|
14
|
+
"cwd": "${workspaceRoot}",
|
|
15
|
+
"runtimeArgs": ["--nolazy"],
|
|
16
|
+
"console": "internalConsole"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Basic Style Dictionary
|
|
2
|
+
|
|
3
|
+
This example code is bare-bones to show you what this framework can do. If you have the style-dictionary module installed globally, just cd into this directory and run:
|
|
4
|
+
```bash
|
|
5
|
+
style-dictionary build
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
You should see something like this output:
|
|
9
|
+
```
|
|
10
|
+
Reading config file from ./config.json
|
|
11
|
+
Building all platforms
|
|
12
|
+
|
|
13
|
+
scss
|
|
14
|
+
✔︎ build/scss/_variables.scss
|
|
15
|
+
|
|
16
|
+
android
|
|
17
|
+
✔︎ build/android/font_dimens.xml
|
|
18
|
+
|
|
19
|
+
ios
|
|
20
|
+
✔︎ build/ios/StyleDictionaryColor.h
|
|
21
|
+
✔︎ build/ios/StyleDictionaryColor.m
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Pat yourself on the back, you just built your first style dictionary! Moving on, take a look at what we have built. This should have created a build directory and it should look like this:
|
|
25
|
+
```
|
|
26
|
+
├── android/
|
|
27
|
+
│ ├── font_dimens.xml
|
|
28
|
+
│ ├── colors.xml
|
|
29
|
+
├── scss/
|
|
30
|
+
│ ├── _variables.scss
|
|
31
|
+
├── ios/
|
|
32
|
+
│ ├── StyleDictionaryColor.h
|
|
33
|
+
│ ├── StyleDictionaryColor.m
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If you open `config.json` you will see there are 3 platforms defined: scss, android, ios. Each platform has a transformGroup, buildPath, and files. The buildPath and files of the platform should match up to the files what were built. The files built should look like these:
|
|
37
|
+
|
|
38
|
+
**Android**
|
|
39
|
+
```xml
|
|
40
|
+
<!-- font_dimens.xml -->
|
|
41
|
+
<resources>
|
|
42
|
+
<dimen name="size_font_small">12.00sp</dimen>
|
|
43
|
+
<dimen name="size_font_medium">16.00sp</dimen>
|
|
44
|
+
<dimen name="size_font_large">32.00sp</dimen>
|
|
45
|
+
<dimen name="size_font_base">16.00sp</dimen>
|
|
46
|
+
</resources>
|
|
47
|
+
|
|
48
|
+
<!-- colors.xml -->
|
|
49
|
+
<resources>
|
|
50
|
+
<color name="color_base_gray_light">#CCCCCC</color>
|
|
51
|
+
<color name="color_base_gray_medium">#999999</color>
|
|
52
|
+
<color name="color_base_gray_dark">#111111</color>
|
|
53
|
+
<color name="color_font_base">#111111</color>
|
|
54
|
+
<color name="color_font_secondary">#999999</color>
|
|
55
|
+
<color name="color_font_tertiary">#CCCCCC</color>
|
|
56
|
+
</resources>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**SCSS**
|
|
60
|
+
```scss
|
|
61
|
+
// variables.scss
|
|
62
|
+
$color-base-gray-light: #CCCCCC;
|
|
63
|
+
$color-base-gray-medium: #999999;
|
|
64
|
+
$color-base-gray-dark: #111111;
|
|
65
|
+
$color-font-base: #111111;
|
|
66
|
+
$color-font-secondary: #999999;
|
|
67
|
+
$color-font-tertiary: #CCCCCC;
|
|
68
|
+
$size-font-small: 0.75rem;
|
|
69
|
+
$size-font-medium: 1rem;
|
|
70
|
+
$size-font-large: 2rem;
|
|
71
|
+
$size-font-base: 1rem;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**iOS**
|
|
75
|
+
```objc
|
|
76
|
+
@implementation StyleDictionaryColor
|
|
77
|
+
|
|
78
|
+
+ (UIColor *)color:(StyleDictionaryColorName)colorEnum{
|
|
79
|
+
return [[self values] objectAtIndex:colorEnum];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
+ (NSArray *)values {
|
|
83
|
+
static NSArray* colorArray;
|
|
84
|
+
static dispatch_once_t onceToken;
|
|
85
|
+
|
|
86
|
+
dispatch_once(&onceToken, ^{
|
|
87
|
+
colorArray = @[
|
|
88
|
+
[UIColor colorWithRed:0.80f green:0.80f blue:0.80f alpha:1.0f],
|
|
89
|
+
[UIColor colorWithRed:0.60f green:0.60f blue:0.60f alpha:1.0f],
|
|
90
|
+
[UIColor colorWithRed:0.07f green:0.07f blue:0.07f alpha:1.0f],
|
|
91
|
+
[UIColor colorWithRed:0.07f green:0.07f blue:0.07f alpha:1.0f],
|
|
92
|
+
[UIColor colorWithRed:0.60f green:0.60f blue:0.60f alpha:1.0f],
|
|
93
|
+
[UIColor colorWithRed:0.80f green:0.80f blue:0.80f alpha:1.0f]
|
|
94
|
+
];
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return colorArray;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Pretty nifty! This shows a few things happening:
|
|
104
|
+
1. The build system does a deep merge of all the property JSON files defined in the `source` attribute of `config.json`. This allows you to split up the property JSON files however you want. There are 2 JSON files with `color` as the top level key, but they get merged properly.
|
|
105
|
+
1. The build system resolves references to other style properties. `{size.font.medium.value}` gets resolved properly
|
|
106
|
+
1. The build system handles references to property values in other files as well as you can see in `properties/color/font.json`
|
|
107
|
+
|
|
108
|
+
Now lets make a change and see how that affects things. Open up `properties/color/base.json` and change `"#111111"` to `"#000000"`. After you make that change, save the file and re-run the build command `style-dictionary build`. Open up the build files and take a look.
|
|
109
|
+
|
|
110
|
+
**Huzzah!**
|
|
111
|
+
|
|
112
|
+
Now go forth and create! Take a look at all the built-in [transforms](https://amzn.github.io/style-dictionary/#/transforms?id=pre-defined-transforms) and [formats](https://amzn.github.io/style-dictionary/#/formats?id=pre-defined-formats).
|
package/babel.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ['@commitlint/config-conventional'] };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env groovy
|
|
2
|
+
library 'jenkins-shared-library'
|
|
3
|
+
|
|
4
|
+
def productName = 'designsystem' // the name of the product to which this service belongs (jobboard/insights/employerbranding/core-services)
|
|
5
|
+
def octopusInstance = 'thekraken' // the Octopus Deploy instance with which this service should be deployed (octopodes/thekraken/wonderpus)
|
|
6
|
+
def octopusPort = '444' // the port number to use for the Octopus server
|
|
7
|
+
|
|
8
|
+
def (subProductName, branchName) = "${env.JOB_NAME}".tokenize( '/' )
|
|
9
|
+
def octopusCredentialId = "$octopusInstance-api-key"
|
|
10
|
+
def siteName = "$productName/$subProductName"
|
|
11
|
+
def repositoryUri = "426517516965.dkr.ecr.eu-west-1.amazonaws.com"
|
|
12
|
+
def octopusUri = "https://$octopusInstance:$octopusPort"
|
|
13
|
+
|
|
14
|
+
println("Target Octopus instance: $octopusInstance")
|
|
15
|
+
println("Target Octopus URI: $octopusUri")
|
|
16
|
+
|
|
17
|
+
pipeline {
|
|
18
|
+
agent {
|
|
19
|
+
any {
|
|
20
|
+
customWorkspace "workspace/${env.JOB_NAME}/${branchName}".replace('%2F', '-')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
options {
|
|
25
|
+
timeout(time: 1, unit: 'HOURS')
|
|
26
|
+
disableConcurrentBuilds()
|
|
27
|
+
skipStagesAfterUnstable()
|
|
28
|
+
skipDefaultCheckout()
|
|
29
|
+
buildDiscarder(logRotator(daysToKeepStr: '5', numToKeepStr: '3'))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
stages {
|
|
33
|
+
stage('SCM') {
|
|
34
|
+
steps {
|
|
35
|
+
notifySlack('STARTED', 'madgex-design-system', 'jenkins-slack-token')
|
|
36
|
+
checkout scm
|
|
37
|
+
notifyBitbucketWithState('INPROGRESS')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
stage('Build') {
|
|
42
|
+
environment {
|
|
43
|
+
GITHUB_TOKEN = credentials('MDS_GITHUB_TOKEN')
|
|
44
|
+
NPM_TOKEN = credentials('MDS_NPM_TOKEN')
|
|
45
|
+
}
|
|
46
|
+
steps {
|
|
47
|
+
script {
|
|
48
|
+
withCredentials([string(credentialsId: octopusCredentialId, variable: 'OctopusApiKey')]) {
|
|
49
|
+
def versionNumber = "0.0.0"
|
|
50
|
+
def currentVersionNumber = sh(returnStdout: true, script: "curl -X GET '${octopusUri}/api/packages?NuGetPackageId=${productName}.${subProductName}&take=1' -H 'X-Octopus-ApiKey: ${OctopusApiKey}' -H 'accept: application/json' --insecure --silent | jq .Items[0].Version -r")
|
|
51
|
+
println("Current version number is ${currentVersionNumber}")
|
|
52
|
+
try {
|
|
53
|
+
def (major, minor, rev) = "${currentVersionNumber}".tokenize( '.' )
|
|
54
|
+
def newRev = (rev.toInteger() + 1).toString()
|
|
55
|
+
versionNumber = "${major}.${minor}.${newRev}"
|
|
56
|
+
} catch (e) {
|
|
57
|
+
echo "Error generating version number."
|
|
58
|
+
versionNumber = "0.0.1"
|
|
59
|
+
}
|
|
60
|
+
println("New version number is ${versionNumber}")
|
|
61
|
+
def tarpackage = "${productName}.${subProductName}.${versionNumber}.tar"
|
|
62
|
+
println(tarpackage)
|
|
63
|
+
sh """
|
|
64
|
+
node --version
|
|
65
|
+
npm --version
|
|
66
|
+
npm ci
|
|
67
|
+
npm run semantic-release
|
|
68
|
+
cd $WORKSPACE
|
|
69
|
+
tar -cvf ${tarpackage} ./public
|
|
70
|
+
"""
|
|
71
|
+
archiveArtifacts "${tarpackage}"
|
|
72
|
+
deployToOctopus.pushPackage(tarpackage, octopusUri, octopusCredentialId)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
post {
|
|
81
|
+
failure {
|
|
82
|
+
script {
|
|
83
|
+
notifyBitbucketWithState('FAILURE')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
success {
|
|
87
|
+
script {
|
|
88
|
+
notifyBitbucketWithState('SUCCESS')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
always {
|
|
92
|
+
script {
|
|
93
|
+
// Necessary to get emailer to send out on success
|
|
94
|
+
currentBuild.result = currentBuild.currentResult
|
|
95
|
+
}
|
|
96
|
+
notifySlack(currentBuild.result, 'madgex-design-system', 'jenkins-slack-token')
|
|
97
|
+
cleanWs deleteDirs: true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Colour Palette | Madgex Design System
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Using color tokens
|
|
6
|
+
|
|
7
|
+
Your context and coding style determine how you access MDS color tokens in code.
|
|
8
|
+
|
|
9
|
+
| Context | Usage | Example |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| function | `color: color(color)` | `color: color('primary')` |
|
|
12
|
+
|
|
13
|
+
{# <pre>{{ tokens.color | dump }}</pre> #}
|
|
14
|
+
|
|
15
|
+
{% macro swatch(item) %}
|
|
16
|
+
<div class="color">
|
|
17
|
+
<div class="swatch" style="background-color: {{ item.value }}"></div>
|
|
18
|
+
<span>{{ item.value }}</span>
|
|
19
|
+
<span>{{ item.comment }}</span>
|
|
20
|
+
<span>
|
|
21
|
+
<em>SCSS:</em>
|
|
22
|
+
{{ item.path }}
|
|
23
|
+
</span>
|
|
24
|
+
<span>
|
|
25
|
+
<em>JavaScript:</em>
|
|
26
|
+
{{item.name}}
|
|
27
|
+
</span>
|
|
28
|
+
{# <pre>{{ item | jsonify }}</pre> #}
|
|
29
|
+
</div>
|
|
30
|
+
{% endmacro %}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<div class="colors">
|
|
34
|
+
{% for key, item in tokens.color %}
|
|
35
|
+
{% if not 'value' in item and item | length %}
|
|
36
|
+
{% for subkey, subitem in item %}
|
|
37
|
+
{{ swatch(subitem) }}
|
|
38
|
+
{% endfor %}
|
|
39
|
+
{% else %}
|
|
40
|
+
{{ swatch(item) }}
|
|
41
|
+
{% endif %}
|
|
42
|
+
{% endfor %}
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.colors {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.colors .color {
|
|
8
|
+
flex: 1 1 calc(33% - 10px);
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: 0;
|
|
11
|
+
margin: 0 10px 0 0;
|
|
12
|
+
padding: 16px;
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
margin-bottom: 24px;
|
|
16
|
+
box-shadow: 0 0 0 1px rgba(63, 63, 68, 0.05),
|
|
17
|
+
0 1px 3px 0 rgba(63, 63, 68, 0.15);
|
|
18
|
+
font-size: 13px;
|
|
19
|
+
color: #001123;
|
|
20
|
+
border-radius: 3px;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
text-align: left;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.color span {
|
|
26
|
+
display: block;
|
|
27
|
+
}
|
|
28
|
+
.color em {
|
|
29
|
+
opacity: 0.8;
|
|
30
|
+
font-style: normal;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.swatch {
|
|
34
|
+
margin-bottom: 16px;
|
|
35
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
|
36
|
+
height: 128px;
|
|
37
|
+
margin-left: -16px;
|
|
38
|
+
margin-top: -16px;
|
|
39
|
+
width: calc(100% + 48px);
|
|
40
|
+
float: left;
|
|
41
|
+
}
|
package/fractal.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const Fractal = require('@frctl/fractal');
|
|
2
|
+
|
|
3
|
+
const fractal = Fractal.create();
|
|
4
|
+
// const fractal = (module.exports = require('@frctl/fractal').create());
|
|
5
|
+
const mandelbrot = require('@frctl/mandelbrot');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const nunjucks = require('@frctl/nunjucks')({
|
|
8
|
+
paths: [path.resolve(__dirname, 'src/components'), path.resolve(__dirname, 'src/')],
|
|
9
|
+
// pristine: true,
|
|
10
|
+
filters: {
|
|
11
|
+
// filter-name: function filterFunc(){}
|
|
12
|
+
jsonify: (d) => JSON.stringify(d, null, ' '),
|
|
13
|
+
dataurl: (d, type) => `data:${type},${encodeURIComponent(d)}`,
|
|
14
|
+
},
|
|
15
|
+
globals: {
|
|
16
|
+
// global-name: global-val
|
|
17
|
+
},
|
|
18
|
+
extensions: {
|
|
19
|
+
// extension-name: function extensionFunc(){}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const pkg = require('./package.json');
|
|
23
|
+
const tokens = require('./tokens/build/js/_variables-module');
|
|
24
|
+
|
|
25
|
+
fractal.components.engine(nunjucks); // use Nunjucks for components
|
|
26
|
+
fractal.components.set('ext', '.njk');
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Give your project a title.
|
|
30
|
+
*/
|
|
31
|
+
fractal.set('project.title', 'Madgex Design System');
|
|
32
|
+
fractal.set('project.version', pkg.version);
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Tell Fractal where to look for components.
|
|
36
|
+
*/
|
|
37
|
+
fractal.components.set('path', path.join(__dirname, 'src/components'));
|
|
38
|
+
fractal.components.set('default.collated', 'true');
|
|
39
|
+
fractal.components.set('default.preview', '@preview');
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Tell Fractal where to look for documentation pages.
|
|
43
|
+
*/
|
|
44
|
+
fractal.docs.engine(nunjucks);
|
|
45
|
+
fractal.docs.set('ext', '.njk'); // default is '.md'
|
|
46
|
+
fractal.docs.set('path', path.join(__dirname, 'docs'));
|
|
47
|
+
fractal.docs.set('default.context', {
|
|
48
|
+
tokens,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Tell the Fractal web preview plugin where to look for static assets.
|
|
53
|
+
*/
|
|
54
|
+
fractal.web.set('static.path', path.join(__dirname, '/dist'));
|
|
55
|
+
|
|
56
|
+
const madgexTheme = mandelbrot({
|
|
57
|
+
// skin: 'black',
|
|
58
|
+
// any other theme configuration values here
|
|
59
|
+
// nav: ['docs', 'components'],
|
|
60
|
+
// which panels to show
|
|
61
|
+
panels: ['html', 'notes', 'view', 'context', 'resources', 'info'],
|
|
62
|
+
styles: ['default', '/assets/css/styles.css'],
|
|
63
|
+
// scripts: ['default', '/assets/theme/js/scripts.js'],
|
|
64
|
+
});
|
|
65
|
+
/*
|
|
66
|
+
* Specify a template directory to override any view templates
|
|
67
|
+
*/
|
|
68
|
+
madgexTheme.addLoadPath(`${__dirname}/fractal-theme/views`);
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
* Specify the static assets directory that contains the custom stylesheet.
|
|
72
|
+
*/
|
|
73
|
+
madgexTheme.addStatic(`${__dirname}/fractal-theme/assets`, '/assets');
|
|
74
|
+
|
|
75
|
+
fractal.web.theme(madgexTheme);
|
|
76
|
+
|
|
77
|
+
/* Set the static HTML build destination */
|
|
78
|
+
fractal.web.set('builder.dest', `${__dirname}/public`);
|
|
79
|
+
|
|
80
|
+
module.exports = fractal;
|
package/gulpfile.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const gulp = require('gulp');
|
|
2
|
+
const del = require('del');
|
|
3
|
+
const { tokens } = require('./tasks/tokens');
|
|
4
|
+
const { css } = require('./tasks/css');
|
|
5
|
+
const { fractalStart, fractalBuild } = require('./tasks/fractal');
|
|
6
|
+
|
|
7
|
+
// ---
|
|
8
|
+
|
|
9
|
+
async function clean(cb) {
|
|
10
|
+
await del(['dist/']);
|
|
11
|
+
cb();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function watchFiles() {
|
|
15
|
+
gulp.watch(['src/core/**/*.scss', 'src/components/**/*.scss'], { awaitWriteFinish: true }, gulp.series(css));
|
|
16
|
+
gulp.watch('tokens/**/*.json', gulp.series(tokens));
|
|
17
|
+
// gulp.watch('./assets/js/**/*', gulp.series(scriptsLint, scripts));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const watch = gulp.parallel(watchFiles);
|
|
21
|
+
const build = gulp.series(clean, tokens, css, fractalBuild);
|
|
22
|
+
const dev = gulp.series(build, fractalStart, watch);
|
|
23
|
+
|
|
24
|
+
exports.clean = clean;
|
|
25
|
+
exports.css = css;
|
|
26
|
+
exports.build = build;
|
|
27
|
+
exports.dev = dev;
|
|
28
|
+
exports.tokens = tokens;
|
|
29
|
+
exports.watch = watch;
|
|
30
|
+
exports.default = build;
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@madgex/design-system",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"commit": "commit",
|
|
6
|
+
"semantic-release": "semantic-release --prepare && npm run build && semantic-release --publish",
|
|
7
|
+
"tokens": "style-dictionary --config ./tokens/_config.js build",
|
|
8
|
+
"dev": "gulp dev",
|
|
9
|
+
"build": "npm run tokens && gulp build",
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"lint-fix": "eslint . --fix"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/jameswragg/madgex-design-system"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.4.4",
|
|
20
|
+
"@babel/preset-env": "^7.4.4",
|
|
21
|
+
"@commitlint/cli": "^7.5.2",
|
|
22
|
+
"@commitlint/config-conventional": "^7.5.0",
|
|
23
|
+
"@commitlint/prompt-cli": "^7.5.0",
|
|
24
|
+
"@frctl/fractal": "^1.1.7",
|
|
25
|
+
"@frctl/mandelbrot": "^1.2.1",
|
|
26
|
+
"@frctl/nunjucks": "^2.0.0",
|
|
27
|
+
"@madgex/eslint-config-madgex": "^1.2.0",
|
|
28
|
+
"commitizen": "^3.0.7",
|
|
29
|
+
"cz-conventional-changelog": "^2.1.0",
|
|
30
|
+
"del": "^4.1.0",
|
|
31
|
+
"flat": "^4.1.0",
|
|
32
|
+
"gulp": "^4.0.0",
|
|
33
|
+
"gulp-sass": "^4.0.2",
|
|
34
|
+
"gulp-tap": "^1.0.1",
|
|
35
|
+
"husky": "^1.3.1",
|
|
36
|
+
"lint-staged": "^8.1.5",
|
|
37
|
+
"semantic-release": "^15.13.3",
|
|
38
|
+
"style-dictionary": "^2.7.0"
|
|
39
|
+
},
|
|
40
|
+
"config": {
|
|
41
|
+
"commitizen": {
|
|
42
|
+
"path": "node_modules/cz-conventional-changelog"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"husky": {
|
|
46
|
+
"hooks": {
|
|
47
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"lint-staged": {
|
|
51
|
+
"*.js": [
|
|
52
|
+
"npm run lint",
|
|
53
|
+
"git add"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{# Determine type of element to use, if not explicitly set -#}
|
|
2
|
+
|
|
3
|
+
{% if params.element %}
|
|
4
|
+
{% set element = params.element | lower %}
|
|
5
|
+
{% else %}
|
|
6
|
+
{% if params.href %}
|
|
7
|
+
{% set element = 'a' %}
|
|
8
|
+
{% else %}
|
|
9
|
+
{% set element = 'button' %}
|
|
10
|
+
{% endif %}
|
|
11
|
+
{% endif %}
|
|
12
|
+
|
|
13
|
+
{#- Define common attributes that we can use across all element types #}
|
|
14
|
+
|
|
15
|
+
{%- set commonAttributes %} class="mds-button{% if params.classes %} {{ params.classes }}{% endif %}{% if params.disabled %} mds-button--disabled{% endif %}"{% for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}{% endset %}
|
|
16
|
+
|
|
17
|
+
{#- Define common attributes we can use for both button and input types #}
|
|
18
|
+
|
|
19
|
+
{%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% endset %}
|
|
20
|
+
|
|
21
|
+
{#- Actually create a button... or a link! #}
|
|
22
|
+
|
|
23
|
+
{%- if element == 'a' %}
|
|
24
|
+
<a href="{{ params.href if params.href else '#' }}" role="button" draggable="false" {{- commonAttributes | safe }}>
|
|
25
|
+
{{ params.html | safe if params.html else params.text }}
|
|
26
|
+
</a>
|
|
27
|
+
|
|
28
|
+
{%- elseif element == 'button' %}
|
|
29
|
+
<button {%- if params.value %} value="{{ params.value }}"{% endif %} {{- buttonAttributes | safe }} {{- commonAttributes | safe }}>
|
|
30
|
+
{{ params.html | safe if params.html else params.text }}
|
|
31
|
+
</button>
|
|
32
|
+
|
|
33
|
+
{%- elseif element == 'input' %}
|
|
34
|
+
<input value="{{ params.text }}" {{- buttonAttributes | safe }} {{- commonAttributes | safe }}>
|
|
35
|
+
{%- endif %}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
title: 'Buttons',
|
|
3
|
+
context: {
|
|
4
|
+
text: 'Button 1',
|
|
5
|
+
},
|
|
6
|
+
variants: [
|
|
7
|
+
{
|
|
8
|
+
name: 'link-buttons',
|
|
9
|
+
context: {
|
|
10
|
+
href: 'http://madgex.com',
|
|
11
|
+
text: 'Link button 2',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'input-buttons',
|
|
16
|
+
context: {
|
|
17
|
+
element: 'input',
|
|
18
|
+
text: 'Input button 3',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.mds-button {
|
|
2
|
+
@include mds-focusable;
|
|
3
|
+
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
user-select: none;
|
|
6
|
+
vertical-align: middle;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
-webkit-appearance: none;
|
|
9
|
+
|
|
10
|
+
border: 1px solid transparent;
|
|
11
|
+
color: $mds-color-white;
|
|
12
|
+
padding: $mds-size-space-xs $mds-size-space-sm;
|
|
13
|
+
background-color: $mds-color-primary;
|
|
14
|
+
font-size: 100%;
|
|
15
|
+
width: 100%;
|
|
16
|
+
display: inline-block;
|
|
17
|
+
text-align: center;
|
|
18
|
+
|
|
19
|
+
@include mq($from: tablet) {
|
|
20
|
+
width: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Ensure that any global link styles are overridden
|
|
24
|
+
&:link,
|
|
25
|
+
&:visited,
|
|
26
|
+
&:active,
|
|
27
|
+
&:hover {
|
|
28
|
+
color: $mds-color-white;
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:hover,
|
|
33
|
+
&:focus {
|
|
34
|
+
// background-color: $mds-color-primary-hover-colour;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>{{ _target.title }} - {{ _config.project.title }}</title>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<link rel="stylesheet" href="{{ '/css/index.css' | path }}">
|
|
8
|
+
|
|
9
|
+
</head>
|
|
10
|
+
<body style="padding: 30px;">
|
|
11
|
+
|
|
12
|
+
{{ yield | safe }}
|
|
13
|
+
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
16
|
+
|