@cityway/design-tokens 1.0.1-beta001

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.
@@ -0,0 +1,26 @@
1
+ @use "sass:map";
2
+ @use "primitives" as p;
3
+
4
+ @function size($key) {
5
+ @return map.get(p.$sizing, $key);
6
+ }
7
+
8
+ @function color($type, $variant) {
9
+ @return map.get(p.$colors, $type, $variant);
10
+ }
11
+
12
+ @function border($type, $variant) {
13
+ @return map.get(p.$border, $type, $variant);
14
+ }
15
+
16
+ @function font($type, $variant) {
17
+ @return map.get(p.$font, $type, $variant);
18
+ }
19
+
20
+ @function hex-to-rgb($hex) {
21
+ @return red($hex), green($hex), blue($hex);
22
+ }
23
+
24
+ @function grid($type, $variant) {
25
+ @return map.get(p.$grid, $type, $variant);
26
+ }
package/_index.scss ADDED
@@ -0,0 +1,3 @@
1
+ @forward "primitives";
2
+ @forward "functions";
3
+ @forward "theme-mapping";
@@ -0,0 +1,239 @@
1
+ @use "sass:map";
2
+
3
+ $prefix: cw;
4
+
5
+ $dropshadow-blur: (
6
+ none: 0rem,
7
+ xs: 0.125rem,
8
+ sm: 0.25rem,
9
+ md: 0.5rem
10
+ );
11
+
12
+ $dropshadow-spread: (
13
+ none: 0rem,
14
+ xs: 0.125rem
15
+ );
16
+
17
+ $dropshadow-position: (
18
+ xs: 0.0625rem,
19
+ sm: 0.125rem,
20
+ md: 0.25rem
21
+ );
22
+
23
+ // Grid
24
+ $grid: (
25
+ breakpoints: (
26
+ xs: 0,
27
+ sm: 576px,
28
+ md: 768px,
29
+ lg: 992px,
30
+ xl: 1200px,
31
+ xxl: 1400px
32
+ ),
33
+ columns: (
34
+ number: 12,
35
+ gutter: 1rem
36
+ )
37
+ );
38
+
39
+ // On récupère la gouttière de la map pour le calcul SASS
40
+ $current-gutter: map.get($grid, "columns", "gutter");
41
+
42
+ // On génère dynamiquement les max-widths
43
+ $calculated-container-widths: ();
44
+ @each $bp, $value in map.get($grid, "breakpoints") {
45
+ @if $value > 0 {
46
+ // Calcul : Breakpoint - (Gouttière * 2)
47
+ $calc-width: $value - ($current-gutter * 2);
48
+ $calculated-container-widths: map.merge($calculated-container-widths, ($bp: $calc-width));
49
+ }
50
+ }
51
+
52
+ // On met à jour la map globale pour ton mixin generate-grid-vars
53
+ $grid: map.merge($grid, ("container-max-widths": $calculated-container-widths));
54
+
55
+ // Colors
56
+ // ---------------------------------
57
+ $colors: (
58
+ base: (
59
+ dark: #1A1A1A,
60
+ "black": #000000,
61
+ "white": #ffffff,
62
+ disabled: #696969,
63
+ w-overlay: rgba(#ffffff, 0),
64
+ w-overlay-90: rgba(#ffffff, 0.9)
65
+ ),
66
+ "grey": (
67
+ b-overlay-10: rgba(#000000, 0.1),
68
+ b-overlay-15: rgba(#000000, 0.15),
69
+ b-overlay-20: rgba(#000000, 0.2),
70
+ b-overlay-35: rgba(#000000, 0.35),
71
+ b-overlay-40: rgba(#000000, 0.4),
72
+ b-overlay-50: rgba(#000000, 0.5),
73
+ 50: #F9F9F9,
74
+ 100: #F2F2F2,
75
+ 200: #E6E6E6,
76
+ 250: #DFDFDF,
77
+ 300: #CCCCCC,
78
+ 400: #B5B5B5,
79
+ 500: #939393,
80
+ 600: #828282,
81
+ 700: #696969,
82
+ 800: #444444,
83
+ 900: #313131,
84
+ 950: #1A1A1A
85
+ ),
86
+ primary: (
87
+ p-overlay-25: rgba(#107099, 0.25),
88
+ p-overlay-50: rgba(#107099, 0.5),
89
+ 500: #107099,
90
+ 600: #0D5878
91
+ ),
92
+ info: (
93
+ 50: #DEE8FD,
94
+ 400: #0F58E0,
95
+ 500: #0B40A2
96
+ ),
97
+ success: (
98
+ s-overlay-50: rgba(#44853C, 0.5),
99
+ 50: #EBF5EA,
100
+ 500: #44853C,
101
+ 600: #366930
102
+ ),
103
+ warning: (
104
+ w-overlay-50: rgba(#E8580C, 0.5),
105
+ 50: #FFF9E6,
106
+ 500: #E8580C,
107
+ 600: #DF3603
108
+ ),
109
+ danger: (
110
+ d-overlay-50: rgba(#E1001A, 0.5),
111
+ 50: #FFE5E8,
112
+ 500: #E1001A,
113
+ 600: #B30015
114
+ ),
115
+ disruption: (
116
+ 50: #FFE5E8,
117
+ 500: #E1001A
118
+ ),
119
+ accessibility: (
120
+ 500: #387DA2
121
+ ),
122
+ carbon: (
123
+ success: #44853C,
124
+ warning: #E8580C,
125
+ danger: #E1001A
126
+ ),
127
+ loyalty: (
128
+ 500: #FDCC55
129
+ ),
130
+ poi: (
131
+ black-500: #1A1A1A,
132
+ black-overlay-50: rgba(#000000, 0.5),
133
+ blue-500: #115FC5,
134
+ blue-overlay-50: rgba(#115FC5, 0.5),
135
+ green-500: #007575,
136
+ green-overlay-50: rgba(#007575, 0.5),
137
+ purple-500: #9B51E0,
138
+ purple-overlay-50: rgba(#9B51E0, 0.5),
139
+ red-500: #B04A5A,
140
+ red-overlay-50: rgba(#B04A5A, 0.5),
141
+ ),
142
+ real-time: (
143
+ success: #7C9E71,
144
+ warning: #D97C4A,
145
+ danger: #E47185,
146
+ disabled: rgba(#696969, 0.5)
147
+ ),
148
+ );
149
+
150
+ // Colors
151
+ // ---------------------------------
152
+ $sizing: (
153
+ none: 0rem,
154
+ 5xs: 0.125rem,
155
+ 4xs: 0.25rem,
156
+ 3xs: 0.375rem,
157
+ 2xs: 0.5rem,
158
+ xs: 0.625rem,
159
+ sm: 0.75rem,
160
+ md: 1rem,
161
+ lg: 1.25rem,
162
+ xl: 1.5rem,
163
+ 2xl: 2rem,
164
+ 3xl: 2.5rem,
165
+ 4xl: 3rem,
166
+ 5xl: 3.5rem,
167
+ 6xl: 3.75rem,
168
+ 7xl: 5rem,
169
+ 8xl: 6.25rem
170
+ );
171
+
172
+ $border: (
173
+ br: ( // border-radius
174
+ none: map.get($sizing, none),
175
+ round: map.get($sizing, 8xl),
176
+ xs: map.get($sizing, 4xs),
177
+ md: map.get($sizing, 2xs),
178
+ xl: map.get($sizing, sm),
179
+ 2xl: map.get($sizing, md),
180
+ 3xl: map.get($sizing, lg),
181
+ 4xl: map.get($sizing, xl),
182
+ ),
183
+ bw: ( //border-width
184
+ none: map.get($sizing, none),
185
+ xs: 0.0625rem,
186
+ sm: map.get($sizing, 5xs),
187
+ md: 0.1875rem,
188
+ lg: map.get($sizing, 4xs)
189
+ ),
190
+ bs: ( // box-shadow
191
+ md: 0 0.25rem 1rem -0.063rem rgba(#000000, 0.1)
192
+ )
193
+ );
194
+
195
+ $font: (
196
+ ff: ( //font-family
197
+ nunito: "Nunito",
198
+ opensans: "Open Sans",
199
+ poppins: "Poppins",
200
+ helvetica: "Helvetica"
201
+ ),
202
+ fs: ( // font-size
203
+ 6xl: map.get($sizing, 7xl),
204
+ 5xl: map.get($sizing, 5xl),
205
+ 4xl: map.get($sizing, 3xl),
206
+ 3xl: map.get($sizing, 2xl),
207
+ 2xl: map.get($sizing, xl),
208
+ xl: map.get($sizing, lg),
209
+ lg: 1.125rem,
210
+ md: map.get($sizing, md),
211
+ md-rwd: map.get($sizing, md),
212
+ sm: 0.875rem,
213
+ xs: map.get($sizing, sm),
214
+ 2xs: map.get($sizing, xs),
215
+ 3xs: map.get($sizing, 2xs),
216
+ ),
217
+ fw: ( // font weight
218
+ light: 300,
219
+ regular: 400,
220
+ semibold: 600,
221
+ bold: 700,
222
+ extrabold: 800
223
+ ),
224
+ lh: ( // line-height
225
+ 6xl: 1.15,
226
+ 5xl: 1.25,
227
+ 4xl: 1.2,
228
+ 3xl: 1.25,
229
+ 2xl: 1.333,
230
+ xl: 1.4,
231
+ lg: 1.5,
232
+ md: 1.5,
233
+ md-rwd: 1.5,
234
+ sm: 1.43,
235
+ xs: 1.333,
236
+ 2xs: 1.4,
237
+ 3xs: 1.2
238
+ )
239
+ );
@@ -0,0 +1,231 @@
1
+ @use "sass:map";
2
+ @use "primitives" as *;
3
+ @use "functions" as *;
4
+
5
+
6
+ // THEME FO
7
+ ////////////////////////////////////////////////////////////////
8
+
9
+ $theme-fo-colors: (
10
+ base: (
11
+ dark: #1A1A1A,
12
+ "black": #000000,
13
+ "white": #ffffff,
14
+ disabled: #696969
15
+ ),
16
+ primary: (
17
+ base: color(primary, 500),
18
+ hover: color(primary, 600),
19
+ contrasted: color(base, "white")
20
+ ),
21
+ secondary: (
22
+ base: color(primary, 500),
23
+ hover: color(primary, 600),
24
+ contrasted: color(base, "white")
25
+ ),
26
+ success: (
27
+ base: color(success, 500),
28
+ hover: color(success, 600),
29
+ contrasted: color(base, "white"),
30
+ light: color(success, 50)
31
+ ),
32
+ info: (
33
+ base: color(info, 500),
34
+ hover: color(info, 400),
35
+ contrasted: color(base, "white"),
36
+ light: color(info, 50)
37
+ ),
38
+ warning: (
39
+ base: color(warning, 500),
40
+ hover: color(warning, 600),
41
+ contrasted: color("grey", 950),
42
+ light: color(warning, 50)
43
+ ),
44
+ danger: (
45
+ base: color(danger, 500),
46
+ hover: color(danger, 600),
47
+ contrasted: color(base, "white"),
48
+ light: color(danger, 50)
49
+ ),
50
+ light: (
51
+ base: color("grey", 50),
52
+ hover: color("grey", 100),
53
+ contrasted: color("grey", 900)
54
+ ),
55
+ dark: (
56
+ base: color(base, dark),
57
+ hover: color("grey", 950),
58
+ contrasted: color(base, "white")
59
+ ),
60
+ disabled: (
61
+ base: color(base, disabled),
62
+ contrasted: color(base, "white")
63
+ ),
64
+ body: (
65
+ bg: color(base, "white"),
66
+ color: color("grey", 950)
67
+ ),
68
+ link: (
69
+ color: color(primary, 500),
70
+ hover: color(primary, 600)
71
+ ),
72
+ );
73
+
74
+ $theme-fo-props: (
75
+ body: (
76
+ fs: 1rem,
77
+ fw: 400,
78
+ lh: 1.5,
79
+ ff-heading: ('"#{font(ff, nunito)}"', sans-serif),
80
+ ff-text: ('"#{font(ff, nunito)}"', sans-serif)
81
+ ),
82
+ link: (
83
+ decoration: underline
84
+ ),
85
+ border: (
86
+ radius: border(br, 2xl),
87
+ radius-input: border(br, round)
88
+ ),
89
+ shadow: (
90
+ default: 0 0.25rem 1rem -0.063rem rgba(#000000, 0.1),
91
+ hover: 0 0.25rem 1rem -0.063rem rgba(#000000, 0.35),
92
+ )
93
+ );
94
+
95
+ // THEME BO
96
+ ////////////////////////////////////////////////////////////////
97
+
98
+ $theme-bo-colors: (
99
+ base: (
100
+ dark: #1A1A1A,
101
+ "black": #000000,
102
+ "white": #ffffff,
103
+ disabled: #696969
104
+ ),
105
+ primary: (
106
+ base: #02c0ce,
107
+ hover: #02aeba,
108
+ contrasted: color(base, "white")
109
+ ),
110
+ secondary: (
111
+ base: #777edd,
112
+ hover: #6c72c8,
113
+ contrasted: color(base, "white")
114
+ ),
115
+ success: (
116
+ base: #0acf97,
117
+ hover: #09bb89,
118
+ contrasted: color(base, "white"),
119
+ light: #daf8ef
120
+ ),
121
+ info: (
122
+ base: #45bbe0,
123
+ hover: #3ea9cb,
124
+ contrasted: color(base, "white"),
125
+ light: #e3f5fa
126
+ ),
127
+ warning: (
128
+ base: #f9bc0b,
129
+ hover: #e1aa0a,
130
+ contrasted: color("grey", 950),
131
+ light: #fef5da
132
+ ),
133
+ danger: (
134
+ base: #f1556c,
135
+ hover: #da4d62,
136
+ contrasted: color(base, "white"),
137
+ light: #fde6e9
138
+ ),
139
+ light: (
140
+ base: #eef2f7,
141
+ hover: color("grey", 100),
142
+ contrasted: color("grey", 900)
143
+ ),
144
+ dark: (
145
+ base: #313a46,
146
+ hover: color("grey", 950),
147
+ contrasted: color(base, "white")
148
+ ),
149
+ disabled: (
150
+ base: color(base, disabled),
151
+ contrasted: color(base, "white")
152
+ ),
153
+ body: (
154
+ bg: #f3f6f8,
155
+ color: #4c4c5c
156
+ ),
157
+ link: (
158
+ color: #02c0ce,
159
+ hover: color(primary, 600)
160
+ ),
161
+ );
162
+
163
+
164
+ $theme-bo-props: (
165
+ body: (
166
+ fs: 1rem,
167
+ fw: 400,
168
+ lh: 1.5,
169
+ ff-heading: ('"#{font(ff, nunito)}"', sans-serif),
170
+ ff-text: ('"#{font(ff, nunito)}"', sans-serif)
171
+ ),
172
+ link: (
173
+ decoration: underline
174
+ ),
175
+ border: (
176
+ radius: border(br, md),
177
+ radius-input: border(br, xs)
178
+ ),
179
+ shadow: (
180
+ default: 0 0 35px 0 rgba(154, 161, 171, .15),
181
+ hover: 0 0 35px 0 rgba(154, 161, 171, .35)
182
+ )
183
+ );
184
+
185
+ // MIXINS
186
+ ////////////////////////////////////////////////////////////////
187
+
188
+ @mixin color-with-rgb($name, $color) {
189
+ --#{$name}: #{$color};
190
+
191
+ // On génère la version RGB seulement si c'est une couleur sans alpha
192
+ @if type-of($color) == 'color' and alpha($color) == 1 {
193
+ --#{$name}-rgb: #{hex-to-rgb($color)};
194
+ }
195
+ }
196
+
197
+ @mixin generate-theme-colors($color-mapping) {
198
+ @each $color-name, $variants in $color-mapping {
199
+ @each $variant-name, $value in $variants {
200
+ @if $variant-name == 'base' {
201
+ @include color-with-rgb(#{$prefix}-#{$color-name}, $value);
202
+ } @else {
203
+ @include color-with-rgb(#{$prefix}-#{$color-name}-#{$variant-name}, $value);
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ @mixin generate-theme-props($props-mapping) {
210
+ @each $component-name, $properties in $props-mapping {
211
+ @each $prop-name, $value in $properties {
212
+ @if type-of($value) == 'list' {
213
+ // Pour les listes (comme font-family), on les joint avec des virgules
214
+ --#{$prefix}-#{$component-name}-#{$prop-name}: #{$value};
215
+ } @else {
216
+ --#{$prefix}-#{$component-name}-#{$prop-name}: #{$value};
217
+ }
218
+ }
219
+ }
220
+ }
221
+
222
+ // MIXINS FOR COMMON ELEMENTS
223
+ ////////////////////////////////////////////////////////////////
224
+
225
+ @mixin generate-grid-vars($map) {
226
+ @each $group-name, $group-values in $map {
227
+ @each $key, $value in $group-values {
228
+ --#{$group-name}-#{$key}: #{$value};
229
+ }
230
+ }
231
+ }
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@cityway/design-tokens",
3
+ "version": "1.0.1-beta001",
4
+ "style": "_index.scss",
5
+ "files": [
6
+ "_index.scss",
7
+ "_primitives.scss",
8
+ "_functions.scss",
9
+ "_theme-mapping.scss"
10
+ ]
11
+ }