@buildcanada/charts 0.2.2 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildcanada/charts",
3
- "version": "0.2.2",
3
+ "version": "0.3.2",
4
4
  "description": "A configurable data visualization library for creating interactive charts.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -30,7 +30,11 @@
30
30
  },
31
31
  "homepage": "https://github.com/BuildCanada/bcds#readme",
32
32
  "publishConfig": {
33
- "access": "public"
33
+ "access": "public",
34
+ "dependencies": {
35
+ "@buildcanada/colours": "^0.3.2",
36
+ "@buildcanada/components": "^0.3.2"
37
+ }
34
38
  },
35
39
  "scripts": {
36
40
  "typecheck": "tsc --noEmit",
@@ -54,6 +58,8 @@
54
58
  "react-dom": "^19.0.0"
55
59
  },
56
60
  "dependencies": {
61
+ "@buildcanada/colours": "workspace:*",
62
+ "@buildcanada/components": "workspace:*",
57
63
  "@fortawesome/fontawesome-svg-core": "^6.7.2",
58
64
  "@fortawesome/free-brands-svg-icons": "^6.7.2",
59
65
  "@fortawesome/free-solid-svg-icons": "^6.7.2",
@@ -1,90 +1,188 @@
1
+ /*******************************************************************************
2
+ * Charts Button Component
3
+ *
4
+ * Uses Build Canada design system styling with square corners and brand colors.
5
+ ******************************************************************************/
6
+
1
7
  .charts-btn {
2
8
  @include body-3-medium;
3
- padding: 8.5px 24px;
4
- border: 1px solid transparent;
9
+ display: inline-flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ gap: 8px;
13
+ padding: 10px 24px;
14
+ border: 2px solid transparent;
5
15
  border-radius: 0;
6
16
  text-align: center;
7
- display: block;
8
17
  cursor: pointer;
18
+ transition: all 150ms ease;
19
+ white-space: nowrap;
20
+ text-transform: uppercase;
21
+ letter-spacing: 0.05em;
22
+ font-weight: 500;
23
+
24
+ &:focus-visible {
25
+ outline: 2px solid $auburn;
26
+ outline-offset: 2px;
27
+ }
9
28
 
10
29
  &.charts-btn--icon-only {
11
- padding: 4.5px 9px;
30
+ padding: 8px;
31
+ min-width: 40px;
32
+ min-height: 40px;
12
33
  }
13
34
 
14
- &:disabled {
15
- cursor: default;
16
-
17
- &.charts-btn--solid-blue,
18
- &.charts-btn--solid-dark-blue,
19
- &.charts-btn--solid-light-blue,
20
- &.charts-btn--solid-vermillion {
21
- color: $blue-50;
22
- background-color: $blue-10;
23
- }
24
-
25
- &.charts-btn--outline-vermillion,
26
- &.charts-btn--outline-white {
27
- color: $blue-40;
28
- border-color: $blue-40;
29
- }
35
+ svg {
36
+ font-size: 0.875em;
37
+ transition: transform 150ms ease;
30
38
  }
31
39
 
32
- svg {
33
- font-size: 0.75rem;
40
+ // Animated arrow on hover
41
+ &:hover:not(:disabled) svg.icon-right {
42
+ transform: translateX(4px);
34
43
  }
35
44
  }
36
45
 
46
+ /*******************************************************************************
47
+ * Icon Position Modifiers
48
+ ******************************************************************************/
49
+
37
50
  .charts-btn--icon-right {
38
- margin-left: 0.5rem;
51
+ margin-left: 8px;
39
52
  }
40
53
 
41
54
  .charts-btn--icon-left {
42
- margin-right: 0.5rem;
55
+ margin-right: 8px;
43
56
  }
44
57
 
58
+ /*******************************************************************************
59
+ * Solid Variants
60
+ ******************************************************************************/
61
+
62
+ .charts-btn--solid-auburn,
45
63
  .charts-btn--solid-vermillion {
46
- background-color: $vermillion;
47
- color: #fff;
64
+ background-color: $auburn;
65
+ border-color: $auburn;
66
+ color: $white;
67
+
68
+ &:hover:not(:disabled) {
69
+ background-color: $auburn-600;
70
+ border-color: $auburn-600;
71
+ }
48
72
 
49
- &:hover {
50
- background-color: $accent-vermillion;
73
+ &:active:not(:disabled) {
74
+ background-color: $auburn-700;
75
+ border-color: $auburn-700;
51
76
  }
52
77
  }
53
78
 
54
- .charts-btn--outline-vermillion {
55
- border-color: $vermillion;
56
- color: $vermillion;
79
+ .charts-btn--solid-charcoal {
80
+ background-color: $charcoal;
81
+ border-color: $charcoal;
82
+ color: $white;
57
83
 
58
- &:hover {
59
- border-color: $accent-vermillion;
60
- color: $accent-vermillion;
84
+ &:hover:not(:disabled) {
85
+ background-color: $gray-70;
86
+ border-color: $gray-70;
87
+ }
88
+
89
+ &:active:not(:disabled) {
90
+ background-color: $gray-60;
91
+ border-color: $gray-60;
61
92
  }
62
93
  }
63
94
 
95
+ .charts-btn--solid-cerulean,
64
96
  .charts-btn--solid-blue {
65
- background-color: $blue-60;
66
- color: #fff;
97
+ background-color: $cerulean-500;
98
+ border-color: $cerulean-500;
99
+ color: $white;
67
100
 
68
- &:hover {
69
- background-color: $blue-90;
101
+ &:hover:not(:disabled) {
102
+ background-color: $cerulean-600;
103
+ border-color: $cerulean-600;
104
+ }
105
+
106
+ &:active:not(:disabled) {
107
+ background-color: $cerulean-700;
108
+ border-color: $cerulean-700;
70
109
  }
71
110
  }
72
111
 
73
112
  .charts-btn--solid-dark-blue {
74
- background-color: $blue-95;
75
- color: #fff;
113
+ background-color: $cerulean-900;
114
+ border-color: $cerulean-900;
115
+ color: $white;
76
116
 
77
- &:hover {
78
- background-color: #164377;
117
+ &:hover:not(:disabled) {
118
+ background-color: $cerulean-950;
119
+ border-color: $cerulean-950;
79
120
  }
80
121
  }
81
122
 
82
123
  .charts-btn--solid-light-blue {
83
- background-color: $blue-20;
84
- color: $blue-90;
124
+ background-color: $cerulean-100;
125
+ border-color: $cerulean-100;
126
+ color: $cerulean-900;
127
+
128
+ &:hover:not(:disabled) {
129
+ background-color: $cerulean-200;
130
+ border-color: $cerulean-200;
131
+ }
132
+ }
133
+
134
+ .charts-btn--solid-linen {
135
+ background-color: $linen;
136
+ border-color: $linen;
137
+ color: $charcoal;
138
+
139
+ &:hover:not(:disabled) {
140
+ background-color: $gray-20;
141
+ border-color: $gray-20;
142
+ }
85
143
 
86
- &:hover {
87
- background-color: $blue-10;
144
+ &:active:not(:disabled) {
145
+ background-color: $gray-30;
146
+ border-color: $gray-30;
147
+ }
148
+ }
149
+
150
+ /*******************************************************************************
151
+ * Outline Variants
152
+ ******************************************************************************/
153
+
154
+ .charts-btn--outline-auburn,
155
+ .charts-btn--outline-vermillion {
156
+ background-color: transparent;
157
+ border-color: $auburn;
158
+ color: $auburn;
159
+
160
+ &:hover:not(:disabled) {
161
+ background-color: $auburn;
162
+ color: $white;
163
+ }
164
+
165
+ &:active:not(:disabled) {
166
+ background-color: $auburn-600;
167
+ border-color: $auburn-600;
168
+ color: $white;
169
+ }
170
+ }
171
+
172
+ .charts-btn--outline-charcoal {
173
+ background-color: transparent;
174
+ border-color: $charcoal;
175
+ color: $charcoal;
176
+
177
+ &:hover:not(:disabled) {
178
+ background-color: $charcoal;
179
+ color: $white;
180
+ }
181
+
182
+ &:active:not(:disabled) {
183
+ background-color: $gray-70;
184
+ border-color: $gray-70;
185
+ color: $white;
88
186
  }
89
187
  }
90
188
 
@@ -93,18 +191,41 @@
93
191
  border-color: $white;
94
192
  color: $white;
95
193
 
96
- &:hover {
194
+ &:hover:not(:disabled) {
97
195
  background-color: $white;
98
- color: $blue-90;
196
+ color: $charcoal;
197
+ }
198
+
199
+ &:active:not(:disabled) {
200
+ background-color: $gray-10;
201
+ border-color: $gray-10;
202
+ color: $charcoal;
99
203
  }
100
204
  }
101
205
 
206
+ .charts-btn--outline-cerulean,
102
207
  .charts-btn--outline-light-blue {
103
- border-color: $blue-20;
104
- color: $blue-90;
208
+ background-color: transparent;
209
+ border-color: $cerulean-500;
210
+ color: $cerulean-700;
105
211
 
106
- &:hover {
107
- background-color: $white;
108
- color: $blue-90;
212
+ &:hover:not(:disabled) {
213
+ background-color: $cerulean-500;
214
+ color: $white;
215
+ }
216
+
217
+ &:active:not(:disabled) {
218
+ background-color: $cerulean-600;
219
+ border-color: $cerulean-600;
220
+ color: $white;
109
221
  }
110
222
  }
223
+
224
+ /*******************************************************************************
225
+ * Disabled State
226
+ ******************************************************************************/
227
+
228
+ .charts-btn:disabled {
229
+ opacity: 0.5;
230
+ cursor: not-allowed;
231
+ }
@@ -1,14 +1,23 @@
1
+ /*******************************************************************************
2
+ * Checkbox
3
+ *
4
+ * Custom checkbox styling.
5
+ * Uses Build Canada design system colors.
6
+ ******************************************************************************/
7
+
1
8
  .checkbox {
2
- $checkbox-size: 16px;
9
+ $checkbox-size: 18px;
3
10
 
4
11
  $light-stroke: $gray-30;
5
- $hover-stroke: $blue-30;
6
- $active-fill: $blue-30;
12
+ $hover-stroke: $auburn-500;
13
+ $active-fill: $auburn-500;
7
14
 
8
15
  position: relative;
16
+ display: flex;
17
+ align-items: flex-start;
9
18
 
10
19
  label {
11
- margin: 0; // style leak in admin
20
+ margin: 0;
12
21
  }
13
22
 
14
23
  input {
@@ -27,28 +36,29 @@
27
36
  width: $checkbox-size;
28
37
  height: $checkbox-size;
29
38
 
30
- background: white;
39
+ background: $white;
31
40
  pointer-events: none;
32
- border-radius: 2px;
33
- border: 1px solid $light-stroke;
34
- color: #fff;
41
+ border-radius: 0;
42
+ border: 2px solid $light-stroke;
43
+ color: $white;
35
44
 
36
45
  display: flex;
37
46
  align-items: center;
38
47
  justify-content: center;
48
+ transition: all 150ms ease;
39
49
 
40
50
  svg {
41
51
  font-size: 10px;
42
- padding-left: 0.75px;
43
52
  }
44
53
  }
45
54
 
46
55
  input:focus-visible + .custom {
47
- outline: 2px solid $controls-color;
56
+ outline: 2px solid $auburn;
57
+ outline-offset: 2px;
48
58
  }
49
59
 
50
60
  input:active + .custom {
51
- background: $active-fill;
61
+ background: $auburn-100;
52
62
  }
53
63
 
54
64
  input:checked + .custom {
@@ -57,36 +67,38 @@
57
67
  }
58
68
 
59
69
  input:checked:active + .custom {
60
- background: white;
70
+ background: $auburn-600;
71
+ border-color: $auburn-600;
61
72
  }
62
73
 
63
74
  input:disabled {
64
75
  + .custom {
65
- background: $blue-10;
66
- border-color: $blue-20;
67
- color: $blue-50;
76
+ background: $gray-10;
77
+ border-color: $gray-20;
78
+ color: $gray-50;
68
79
  }
69
80
 
70
81
  &:active + .custom {
71
- background: $blue-10;
82
+ background: $gray-10;
72
83
  }
73
84
 
74
85
  ~ .label {
75
- color: $blue-50;
86
+ color: $gray-50;
76
87
  cursor: not-allowed;
77
88
  }
78
89
  }
79
90
 
80
91
  .label {
81
92
  @include grapher_label-2-regular;
82
- padding-left: $checkbox-size + 8px;
93
+ padding-left: $checkbox-size + 10px;
83
94
  cursor: pointer;
84
95
  user-select: none;
85
- color: $dark-text;
96
+ color: $charcoal;
97
+ line-height: $checkbox-size;
86
98
  }
87
99
 
88
100
  &:hover {
89
- input:not(:checked) + .custom {
101
+ input:not(:checked):not(:disabled) + .custom {
90
102
  border-color: $hover-stroke;
91
103
  }
92
104
  }
@@ -1,20 +1,26 @@
1
+ /*******************************************************************************
2
+ * Labeled Switch
3
+ *
4
+ * Toggle switch with label.
5
+ * Uses Build Canada design system colors.
6
+ ******************************************************************************/
7
+
1
8
  @use "sass:color";
2
9
 
3
10
  $light-fill: $gray-30;
4
- $active-fill: $blue-20;
5
-
6
- $active-switch: $blue-50;
7
-
11
+ $active-fill: $cerulean-100;
12
+ $active-switch: $cerulean-500;
8
13
  $medium: 400;
9
14
  $lato: $sans-serif-font-stack;
10
15
 
11
- // on/off switch with label written to the right
16
+ // On/off switch with label written to the right
12
17
  .labeled-switch {
13
- // keep in sync with TableFilterToggle.tsx
18
+ // Keep in sync with TableFilterToggle.tsx
14
19
  // where the width of a labeled switch is calculated
15
20
 
16
21
  display: flex;
17
- color: $gray-70;
22
+ align-items: center;
23
+ color: $gray-60;
18
24
  font: $medium 13px/16px $lato;
19
25
  letter-spacing: 0.01em;
20
26
 
@@ -24,23 +30,20 @@ $lato: $sans-serif-font-stack;
24
30
  user-select: none;
25
31
 
26
32
  label {
27
- color: $gray-80;
28
- padding-left: 35px;
33
+ color: $charcoal;
34
+ padding-left: 40px;
29
35
  white-space: nowrap;
30
-
31
- &:hover {
32
- cursor: pointer;
33
- }
36
+ cursor: pointer;
34
37
 
35
38
  svg {
36
- color: $gray-60;
39
+ color: $gray-50;
37
40
  height: 13px;
38
41
  padding: 0 0.333em;
39
42
  }
40
43
  }
41
44
 
42
45
  .labeled-switch-subtitle {
43
- // only show subtitle in settings menu, otherwise use icon + tooltip
46
+ // Only show subtitle in settings menu, otherwise use icon + tooltip
44
47
  display: none;
45
48
  }
46
49
 
@@ -48,61 +51,71 @@ $lato: $sans-serif-font-stack;
48
51
  position: absolute;
49
52
  opacity: 0;
50
53
  left: 0;
54
+ cursor: pointer;
51
55
  }
52
56
 
53
57
  .outer {
54
58
  position: absolute;
55
59
  left: 0;
56
- top: 0;
60
+ top: 50%;
61
+ transform: translateY(-50%);
57
62
  content: " ";
58
- width: 29px;
59
- height: 16px;
63
+ width: 32px;
64
+ height: 18px;
60
65
  background: $light-fill;
61
- border-radius: 8px;
66
+ border-radius: 9px;
62
67
  pointer-events: none;
68
+ transition: background 200ms ease;
69
+
63
70
  .inner {
64
71
  position: relative;
65
72
  content: " ";
66
- width: 10px;
67
- height: 10px;
68
- background: $gray-70;
69
- border-radius: 5px;
73
+ width: 12px;
74
+ height: 12px;
75
+ background: $gray-60;
76
+ border-radius: 50%;
70
77
  top: 3px;
71
78
  left: 3px;
72
79
  pointer-events: none;
73
- transition: transform 333ms;
80
+ transition: transform 200ms ease, background 200ms ease;
74
81
  }
75
82
  }
76
83
 
77
84
  &:hover {
78
85
  .outer .inner {
79
- background: $gray-80;
86
+ background: $charcoal;
80
87
  }
81
88
  }
82
89
 
83
90
  input:focus-visible + .outer {
84
- outline: 2px solid $controls-color;
91
+ outline: 2px solid $auburn;
92
+ outline-offset: 2px;
85
93
  }
86
94
 
87
95
  input:checked + .outer {
88
96
  background: $active-fill;
97
+
89
98
  .inner {
90
99
  background: $active-switch;
91
- transform: translate(13px, 0);
100
+ transform: translate(14px, 0);
92
101
  }
93
102
  }
103
+
94
104
  &:hover input:checked + .outer .inner {
95
- background: color.adjust($active-switch, $lightness: -13%);
105
+ background: $cerulean-600;
96
106
  }
97
107
 
98
108
  &.labeled-switch--is-disabled {
99
109
  opacity: 0.5;
110
+ cursor: not-allowed;
111
+
100
112
  label {
101
- cursor: default;
113
+ cursor: not-allowed;
102
114
  }
115
+
103
116
  &:hover {
104
117
  .inner {
105
- background: $gray-70;
118
+ background: $gray-60;
106
119
  }
107
120
  }
108
121
  }
@@ -1,16 +1,25 @@
1
+ /*******************************************************************************
2
+ * Radio Button
3
+ *
4
+ * Custom radio button styling.
5
+ * Uses Build Canada design system colors.
6
+ ******************************************************************************/
7
+
1
8
  @use "sass:math";
2
9
 
3
10
  .radio {
4
- $radio-size: 16px;
11
+ $radio-size: 18px;
5
12
 
6
13
  $light-stroke: $gray-30;
7
- $hover-stroke: $blue-30;
8
- $active-fill: $blue-50;
14
+ $hover-stroke: $cerulean-500;
15
+ $active-fill: $cerulean-500;
9
16
 
10
17
  position: relative;
18
+ display: flex;
19
+ align-items: flex-start;
11
20
 
12
21
  label {
13
- margin: 0; // style leak in admin
22
+ margin: 0;
14
23
  cursor: pointer;
15
24
  }
16
25
 
@@ -28,37 +37,48 @@
28
37
  width: $radio-size;
29
38
  height: $radio-size;
30
39
 
31
- background: white;
40
+ background: $white;
32
41
  pointer-events: none;
33
42
  border-radius: 50%;
34
- border: 1px solid $light-stroke;
43
+ border: 2px solid $light-stroke;
35
44
 
36
45
  display: flex;
37
46
  align-items: center;
38
47
  justify-content: center;
48
+ transition: all 150ms ease;
39
49
 
40
50
  .inner {
41
51
  width: math.div($radio-size, 2);
42
52
  height: math.div($radio-size, 2);
43
53
  background-color: $active-fill;
44
54
  border-radius: 50%;
55
+ opacity: 0;
56
+ transform: scale(0);
57
+ transition: all 150ms ease;
45
58
  }
46
59
  }
47
60
 
48
61
  input:focus-visible + .outer {
49
- outline: 2px solid $controls-color;
62
+ outline: 2px solid $auburn;
63
+ outline-offset: 2px;
50
64
  }
51
65
 
52
66
  input:checked + .outer {
53
67
  border-color: $hover-stroke;
68
+
69
+ .inner {
70
+ opacity: 1;
71
+ transform: scale(1);
72
+ }
54
73
  }
55
74
 
56
75
  .label {
57
76
  @include grapher_label-2-regular;
58
- padding-left: $radio-size + 8px;
77
+ padding-left: $radio-size + 10px;
59
78
  cursor: pointer;
60
79
  user-select: none;
61
- color: $dark-text;
80
+ color: $charcoal;
81
+ line-height: $radio-size;
62
82
  }
63
83
 
64
84
  &:hover {