@cdc/waffle-chart 1.0.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/LICENSE +201 -0
- package/README.md +33 -0
- package/dist/cdcwafflechart.js +6 -0
- package/examples/example-config.json +10 -0
- package/examples/example-data-2.json +32 -0
- package/examples/example-data.json +90 -0
- package/package.json +43 -0
- package/src/CdcWaffleChart.tsx +502 -0
- package/src/components/EditorPanel.js +510 -0
- package/src/context.js +5 -0
- package/src/data/initial-state.js +27 -0
- package/src/index.html +11 -0
- package/src/index.js +16 -0
- package/src/scss/editor-panel.scss +710 -0
- package/src/scss/main.scss +52 -0
- package/src/scss/responsive.scss +1 -0
- package/src/scss/variables.scss +29 -0
- package/src/scss/waffle-chart.scss +127 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
@import '~@cdc/core/styles/base';
|
|
2
|
+
@import "~@cdc/core/styles/heading-colors";
|
|
3
|
+
@import 'variables';
|
|
4
|
+
@import 'waffle-chart';
|
|
5
|
+
|
|
6
|
+
.cdc-open-viz-module.type-waffle-chart {
|
|
7
|
+
@import 'editor-panel';
|
|
8
|
+
|
|
9
|
+
.loader {
|
|
10
|
+
width: 100%;
|
|
11
|
+
text-align: center;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
animation: spin 1s linear infinite;
|
|
14
|
+
|
|
15
|
+
&::before {
|
|
16
|
+
content: '\21BB';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@include breakpointClass(xs) {
|
|
21
|
+
&.font-small {
|
|
22
|
+
font-size: .8em;
|
|
23
|
+
}
|
|
24
|
+
&.font-medium {
|
|
25
|
+
font-size: .9em;
|
|
26
|
+
}
|
|
27
|
+
&.font-large {
|
|
28
|
+
font-size: 1em;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include breakpointClass(md) {
|
|
33
|
+
&.font-small {
|
|
34
|
+
font-size: .9em;
|
|
35
|
+
}
|
|
36
|
+
&.font-large {
|
|
37
|
+
font-size: 1.1em;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@include breakpointClass(lg) {
|
|
42
|
+
&.font-small {
|
|
43
|
+
font-size: 1em;
|
|
44
|
+
}
|
|
45
|
+
&.font-medium {
|
|
46
|
+
font-size: 1.1em;
|
|
47
|
+
}
|
|
48
|
+
&.font-large {
|
|
49
|
+
font-size: 1.2em;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
$theme-colors: (
|
|
2
|
+
"blue": $primary,
|
|
3
|
+
"purple": $purple-primary,
|
|
4
|
+
"brown": $brown-primary,
|
|
5
|
+
"teal": $teal-primary,
|
|
6
|
+
"pink": $pink-primary,
|
|
7
|
+
"orange": $orange-primary,
|
|
8
|
+
"slate": $slate-primary,
|
|
9
|
+
"indigo": $indigo-primary,
|
|
10
|
+
"cyan": $cyan-primary,
|
|
11
|
+
"green": $green-primary,
|
|
12
|
+
"amber": $amber-primary
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
$theme-colors-secondary: (
|
|
16
|
+
"blue": $secondary,
|
|
17
|
+
"purple": $purple-secondary,
|
|
18
|
+
"brown": $brown-secondary,
|
|
19
|
+
"teal": $teal-secondary,
|
|
20
|
+
"pink": $pink-secondary,
|
|
21
|
+
"orange": $orange-secondary,
|
|
22
|
+
"slate": $slate-secondary,
|
|
23
|
+
"indigo": $indigo-secondary,
|
|
24
|
+
"cyan": $cyan-secondary,
|
|
25
|
+
"green": $green-secondary,
|
|
26
|
+
"amber": $amber-secondary
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
$editorWidth: 350px;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
@mixin set-theme($property, $color) {
|
|
2
|
+
@if $property == 'background-color' {
|
|
3
|
+
background-color: $color;
|
|
4
|
+
} @else if $property == 'border-color' {
|
|
5
|
+
border-color: $color;
|
|
6
|
+
} @else if $property == 'color' {
|
|
7
|
+
color: $color;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.cdc-waffle-chart {
|
|
12
|
+
position: relative;
|
|
13
|
+
border: solid 1px #ccc;
|
|
14
|
+
border-top: none;
|
|
15
|
+
box-shadow: rgba(0, 0, 0, 0.2) 3px 6px 10px;
|
|
16
|
+
background: $lightestGray;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
|
|
19
|
+
@at-root .is-editor #{&} {
|
|
20
|
+
margin: 3em auto 0;
|
|
21
|
+
max-width: 35em;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.cdc-waffle-chart__inner-container {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
padding: 1em 1em 0;
|
|
28
|
+
justify-content: flex-start;
|
|
29
|
+
|
|
30
|
+
&.cdc-waffle-chart--verical {
|
|
31
|
+
align-items: center;
|
|
32
|
+
flex-flow: column;
|
|
33
|
+
|
|
34
|
+
.cdc-waffle-chart__chart {
|
|
35
|
+
padding-right: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.cdc-waffle-chart__data {
|
|
39
|
+
text-align: center;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.cdc-waffle-chart__chart {
|
|
45
|
+
padding-right: 1rem;
|
|
46
|
+
margin-bottom: 1rem;
|
|
47
|
+
box-sizing: content-box;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.cdc-waffle-chart__data {
|
|
51
|
+
flex: 1 1 0;
|
|
52
|
+
min-width: 175px;
|
|
53
|
+
margin-bottom: 1rem;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.cdc-waffle-chart__subtext {
|
|
57
|
+
font-style: italic;
|
|
58
|
+
font-weight: bold;
|
|
59
|
+
font-size: 0.75em;
|
|
60
|
+
padding: 0 1em 1em;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cdc-waffle-chart__header {
|
|
65
|
+
@at-root {
|
|
66
|
+
.cdc-waffle-chart #{&} {
|
|
67
|
+
width: 100%;
|
|
68
|
+
padding: 0.6em 0.8em;
|
|
69
|
+
margin: 0 !important;
|
|
70
|
+
border-bottom-width: 3px;
|
|
71
|
+
border-bottom-style: solid;
|
|
72
|
+
font-size: 1.1em;
|
|
73
|
+
color: white;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@each $theme, $color in $theme-colors {
|
|
77
|
+
.cdc-waffle-chart.theme-#{$theme} #{&} {
|
|
78
|
+
@include set-theme("background-color", $color);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
@each $theme, $color in $theme-colors-secondary {
|
|
82
|
+
.cdc-waffle-chart.theme-#{$theme} #{&} {
|
|
83
|
+
@include set-theme("border-color", $color);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.cdc-waffle-chart__data {
|
|
90
|
+
@at-root {
|
|
91
|
+
@each $theme, $color in $theme-colors {
|
|
92
|
+
.cdc-waffle-chart.theme-#{$theme} #{&} {
|
|
93
|
+
@include set-theme("color", $color);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.cdc-waffle-chart.font-small #{&} {
|
|
98
|
+
.cdc-waffle-chart__data--primary { font-size: 35px; }
|
|
99
|
+
.cdc-waffle-chart__data--text { font-size: 14px; }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.cdc-waffle-chart.font-medium #{&} {
|
|
103
|
+
.cdc-waffle-chart__data--primary { font-size: 50px; }
|
|
104
|
+
.cdc-waffle-chart__data--text { font-size: 18px; }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.cdc-waffle-chart.font-large #{&} {
|
|
108
|
+
.cdc-waffle-chart__data--primary { font-size: 80px; }
|
|
109
|
+
.cdc-waffle-chart__data--text { font-size: 20px; }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.cdc-waffle-chart__data--primary {
|
|
114
|
+
font-size: 70px;
|
|
115
|
+
font-weight: 400;
|
|
116
|
+
line-height: 1em;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.cdc-waffle-chart__data--text {
|
|
120
|
+
font-weight: 300;
|
|
121
|
+
line-height: 1.25em;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.cdc-waffle-chart__node {
|
|
126
|
+
transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
127
|
+
}
|