@charcoal-ui/theme 1.0.0-alpha.1 → 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/src/default.ts ADDED
@@ -0,0 +1,159 @@
1
+ import { rgba } from 'polished'
2
+ import { CharcoalTheme } from './theme'
3
+ import {
4
+ BORDER_RADIUS,
5
+ BREAKPOINT,
6
+ COLUMN_UNIT,
7
+ GUTTER_UNIT,
8
+ SPACING,
9
+ TYPOGRAPHY_SIZE,
10
+ } from '@charcoal-ui/foundation'
11
+ import { applyEffect } from '@charcoal-ui/utils'
12
+
13
+ const outlineEffect = {
14
+ type: 'opacity',
15
+ opacity: 0.32,
16
+ } as const
17
+
18
+ const assertive = '#ff2b00'
19
+ const brand = '#0096fa'
20
+
21
+ const common = {
22
+ typography: {
23
+ size: TYPOGRAPHY_SIZE,
24
+ },
25
+ spacing: SPACING,
26
+ grid: {
27
+ unit: {
28
+ column: COLUMN_UNIT,
29
+ gutter: GUTTER_UNIT,
30
+ },
31
+ },
32
+ borderRadius: BORDER_RADIUS,
33
+ transition: {
34
+ default: {
35
+ duration: 0.2,
36
+ },
37
+ },
38
+ breakpoint: {
39
+ screen1: BREAKPOINT[6],
40
+ screen2: BREAKPOINT[8],
41
+ screen3: BREAKPOINT[10],
42
+ screen4: BREAKPOINT[12],
43
+ },
44
+ gradientColor: {
45
+ surface5: [
46
+ { color: rgba('#000000', 0.32), ratio: 0 },
47
+ { color: rgba('#000000', 0), ratio: 100 },
48
+ ],
49
+ callToAction: [
50
+ { color: '#d1ff1a', ratio: 0 },
51
+ { color: '#1ad1ff', ratio: 100 },
52
+ ],
53
+ },
54
+ outline: {
55
+ default: {
56
+ color: applyEffect(brand, outlineEffect),
57
+ weight: 4,
58
+ },
59
+ assertive: {
60
+ color: applyEffect(assertive, outlineEffect),
61
+ weight: 4,
62
+ },
63
+ },
64
+ elementEffect: {
65
+ disabled: {
66
+ type: 'opacity',
67
+ opacity: 0.32,
68
+ },
69
+ },
70
+ } as const
71
+
72
+ export const light: CharcoalTheme = {
73
+ ...common,
74
+ effect: {
75
+ hover: {
76
+ type: 'alpha',
77
+ color: '#000000',
78
+ opacity: 0.08,
79
+ },
80
+ press: {
81
+ type: 'alpha',
82
+ color: '#000000',
83
+ opacity: 0.16,
84
+ },
85
+ },
86
+ color: {
87
+ // TODO: colors should be picked from foundation color palette
88
+ transparent: rgba('#000000', 0),
89
+ background1: '#ffffff',
90
+ background2: '#f5f5f5',
91
+ icon6: rgba('#ffffff', 0.28),
92
+ link1: '#3d7699',
93
+ link2: rgba('#ffffff', 0.36),
94
+ surface1: '#ffffff',
95
+ surface2: rgba('#000000', 0.02),
96
+ surface3: rgba('#000000', 0.04),
97
+ surface4: rgba('#000000', 0.32),
98
+ surface6: rgba('#000000', 0.88),
99
+ surface7: rgba('#000000', 0.02),
100
+ surface8: rgba('#000000', 0.88),
101
+ surface9: rgba('#ffffff', 0.84),
102
+ text1: rgba('#000000', 0.88),
103
+ text2: rgba('#000000', 0.64),
104
+ text3: rgba('#000000', 0.32),
105
+ text4: rgba('#000000', 0.16),
106
+ text5: '#ffffff',
107
+ brand,
108
+ assertive,
109
+ },
110
+ border: {
111
+ default: {
112
+ color: rgba('#000000', 0.08),
113
+ },
114
+ },
115
+ }
116
+
117
+ export const dark: CharcoalTheme = {
118
+ ...common,
119
+ effect: {
120
+ hover: {
121
+ type: 'alpha',
122
+ color: '#000000',
123
+ opacity: 0.08,
124
+ },
125
+ press: {
126
+ type: 'alpha',
127
+ color: '#000000',
128
+ opacity: 0.16,
129
+ },
130
+ },
131
+ color: {
132
+ transparent: rgba('#000000', 0),
133
+ background1: '#1f1f1f',
134
+ background2: '#000000',
135
+ icon6: light.color.icon6,
136
+ link1: light.color.link1,
137
+ link2: light.color.link2,
138
+ surface1: '#1f1f1f',
139
+ surface2: rgba('#000000', 0.16),
140
+ surface3: rgba('#ffffff', 0.12),
141
+ surface4: light.color.surface4,
142
+ surface6: rgba('#ffffff', 0.12),
143
+ surface7: light.color.surface7,
144
+ surface8: light.color.surface8,
145
+ surface9: light.color.surface9,
146
+ text1: '#ffffff',
147
+ text2: rgba('#ffffff', 0.68),
148
+ text3: rgba('#ffffff', 0.36),
149
+ text4: rgba('#ffffff', 0.28),
150
+ text5: light.color.text5,
151
+ brand,
152
+ assertive,
153
+ },
154
+ border: {
155
+ default: {
156
+ color: rgba('#ffffff', 0.12),
157
+ },
158
+ },
159
+ }
package/src/index.ts CHANGED
@@ -1,155 +1,3 @@
1
- import { Effect, Effects, OpacityEffect } from './effect'
2
-
3
- export default {}
4
-
5
- export * from './effect'
6
-
7
- export type Material = string
8
- export type GradientMaterial = { color: Material; ratio: number }[]
9
-
10
- /**
11
- * @deprecated
12
- */
13
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
14
- type ThemeMaterials = {
15
- background1: Material
16
- background2: Material
17
- surface1: Material
18
- surface2: Material
19
- /**
20
- * Black Fade 20にするとボーダーと共通化できる
21
- */
22
- surface3: Material
23
- surface4: Material
24
- // NOTE: the current definition of surface5 is invalid
25
- surface6: Material
26
- /**
27
- * サムネイルに被せる色。
28
- * Lightモードの色が2と共通。コントラストの低下を狙うなら2でいいが、サムネイルで色味を調整しすぎる感がある。
29
- */
30
- surface7: Material
31
- /**
32
- * 磨りガラス効果を使えれば6と統合できそう
33
- */
34
- surface8: Material
35
- surface9: Material
36
- link1: Material
37
- link2: Material
38
- text1: Material
39
- /**
40
- * 1と2は統合できるかもしれない
41
- */
42
- text2: Material
43
- text3: Material
44
- /**
45
- * Surface 4に重ねた時に薄すぎる感あり
46
- */
47
- text4: Material
48
- text5: Material
49
- icon6: Material
50
- border: Material
51
- }
52
-
53
- /**
54
- * @deprecated
55
- */
56
- export interface ThemeEffects {
57
- hover: Effects
58
- press: Effects
59
- disabled: Effects
60
- }
61
-
62
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
63
- export type ThemeEffect = {
64
- hover: Effect
65
- press: Effect
66
- }
67
-
68
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
69
- export type ThemeElementEffect = {
70
- disabled: OpacityEffect
71
- }
72
-
73
- /**
74
- * @deprecated
75
- */
76
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
77
- type ThemeSemantic = {
78
- brand: Material
79
- }
80
-
81
- /**
82
- * @deprecated Use `ThemeColor` instead
83
- */
84
- export type ThemeColors = ThemeMaterials &
85
- ThemeSemantic & {
86
- premium: Material
87
- }
88
-
89
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
90
- export type ThemeColor = {
91
- transparent: Material
92
- background1: Material
93
- background2: Material
94
- surface1: Material
95
- surface2: Material
96
- surface3: Material
97
- surface4: Material
98
- surface6: Material
99
- surface7: Material
100
- surface8: Material
101
- surface9: Material
102
- link1: Material
103
- link2: Material
104
- text1: Material
105
- text2: Material
106
- text3: Material
107
- text4: Material
108
- text5: Material
109
- icon6: Material
110
- border: Material
111
- brand: Material
112
- assertive: Material
113
- /**
114
- * @deprecated
115
- */
116
- premium: Material
117
- }
118
-
119
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
120
- export type ThemeColorGradient = {
121
- surface4Gradient: GradientMaterial
122
- }
123
-
124
- export interface Theme {
125
- /**
126
- * @deprecated
127
- *
128
- * Use `color` instead.
129
- */
130
- materials: ThemeMaterials
131
- /**
132
- * @deprecated
133
- *
134
- * Use `color` instead.
135
- */
136
- semantic: ThemeSemantic
137
- /**
138
- * @deprecated Use `color` instead
139
- */
140
- colors: ThemeColors
141
- color: ThemeColor
142
- gradientColor: ThemeColorGradient
143
- /**
144
- * @deprecated Use `effect` instead
145
- */
146
- effects: ThemeEffects
147
- /**
148
- * effect for color (background or font color)
149
- */
150
- effect: ThemeEffect
151
- /**
152
- * effect for element its own (opacify element includes descendants)
153
- */
154
- elementEffect: ThemeElementEffect
155
- }
1
+ export * from './theme'
2
+ export * from './abstract-theme'
3
+ export * from './default'
package/src/theme.ts ADDED
@@ -0,0 +1,100 @@
1
+ import {
2
+ type GradientMaterial,
3
+ type Material,
4
+ type TypographyDescriptor,
5
+ type Effect,
6
+ type OpacityEffect,
7
+ SPACING,
8
+ BORDER_RADIUS,
9
+ } from '@charcoal-ui/foundation'
10
+ import { CharcoalAbstractTheme } from './abstract-theme'
11
+
12
+ export interface CharcoalTheme extends CharcoalAbstractTheme {
13
+ readonly color: ThemeColor
14
+ readonly gradientColor: ThemeColorGradient
15
+ /**
16
+ * effect for color (background or font color)
17
+ */
18
+ readonly effect: ThemeEffect
19
+ /**
20
+ * effect for element its own (opacify element includes descendants)
21
+ */
22
+ readonly elementEffect: ThemeElementEffect
23
+ readonly spacing: Spacing
24
+ readonly typography: {
25
+ readonly size: Typography
26
+ }
27
+ readonly borderRadius: BorderRadius
28
+ readonly border: {
29
+ readonly default: {
30
+ readonly color: Material
31
+ }
32
+ }
33
+ readonly outline: {
34
+ readonly default: {
35
+ readonly color: string
36
+ readonly weight: 4
37
+ }
38
+ readonly assertive: {
39
+ readonly color: string
40
+ readonly weight: 4
41
+ }
42
+ }
43
+ readonly breakpoint: Breakpoint
44
+ }
45
+
46
+ export type ThemeColor = {
47
+ readonly transparent: Material
48
+ readonly background1: Material
49
+ readonly background2: Material
50
+ readonly surface1: Material
51
+ readonly surface2: Material
52
+ readonly surface3: Material
53
+ readonly surface4: Material
54
+ readonly surface6: Material
55
+ readonly surface7: Material
56
+ readonly surface8: Material
57
+ readonly surface9: Material
58
+ readonly link1: Material
59
+ readonly link2: Material
60
+ readonly text1: Material
61
+ readonly text2: Material
62
+ readonly text3: Material
63
+ readonly text4: Material
64
+ readonly text5: Material
65
+ readonly icon6: Material
66
+ readonly brand: Material
67
+ readonly assertive: Material
68
+ }
69
+
70
+ export type ThemeEffect = {
71
+ readonly hover: Effect
72
+ readonly press: Effect
73
+ }
74
+
75
+ export type ThemeElementEffect = {
76
+ readonly disabled: OpacityEffect
77
+ }
78
+
79
+ export type ThemeColorGradient = {
80
+ readonly surface5: GradientMaterial
81
+ readonly callToAction: GradientMaterial
82
+ }
83
+
84
+ export type Typography = {
85
+ readonly [12]: TypographyDescriptor
86
+ readonly [14]: TypographyDescriptor
87
+ readonly [16]: TypographyDescriptor
88
+ readonly [20]: TypographyDescriptor
89
+ readonly [32]: TypographyDescriptor
90
+ }
91
+
92
+ export type Breakpoint = {
93
+ readonly screen1: number
94
+ readonly screen2: number
95
+ readonly screen3: number
96
+ readonly screen4: number
97
+ }
98
+
99
+ export type Spacing = Readonly<Record<keyof typeof SPACING, number>>
100
+ export type BorderRadius = Readonly<Record<keyof typeof BORDER_RADIUS, number>>