UNPKG

4.24 kBPlain TextView Raw
1import { code, md } from '@kalamazoo/docs';
2
3export default md`
4 ## v9.x.x to v9.3.0 | Breaking Types & Hearts
5
6 This release contains type fixes and documentation improvements.
7
8 ### \`colors\` export
9
10 Previously it was typed as:
11
12${code`
13import { colors } from '@kalamazoo/theme';
14// Record<string, string>
15`}
16
17 The keys of the colors are now typed,
18 so where before you would not have _any_ intellisense - now you **will**!
19
20 It turns out not all colors are strings,
21 some are actually functions!
22 Now the themed colors are typed correctly which will break you if you assumed they were strings.
23
24${code`
25import { colors } from '@kalamazoo/theme';
26
27const key: string = 'B300'; // This would be typed as a string
28const color = colors[key]; // Will now error!
29
30// You can fix this by either typing key as the string literal, or accessing it directly.
31const key: 'B300' = 'B300';
32const color = colors[key]; // No error!
33const color1 = colors.B300; // No error!
34
35// 👇 Will now error! It's actually a function!
36const background: string = colors.background;
37`}
38
39 ### \`elevation\` export
40
41 Previously it was typed as:
42
43${code`
44import { elevation } from '@kalamazoo/theme';
45// Record<string, ThemedValue<string>>
46`}
47
48 Like \`colors\` this would not give you any Intellisense - any key is valid according to this type!
49 Now they're typed according to the exports.
50
51 ### \`layers\` export
52
53 Previously it was typed as:
54
55 ${code`
56 import { layers } from '@kalamazoo/theme';
57 // Record<string, () => number>
58 `}
59
60 Like \`colors\` this would not give you any Intellisense - any key is valid according to this type!
61 Now they're typed according to the exports.
62
63 ### \`typography.headingSizes\` export
64
65 Previously it was typed as:
66
67 ${code`
68 import { typography } from '@kalamazoo/theme';
69
70 typography.headingSizes
71 // Record<string, HeadingSize>
72 `}
73
74 Like \`colors\` this would not give you any Intellisense - any key is valid according to this type!
75 Now they're typed according to the exports.
76
77 Good luck! Remember to raise a ticket over at our [Service Desk](https://ecosystem.atlassian.net/servicedesk/customer/portal/24) if you find anything not working great.
78
79 ## 6.x - 7.x
80
81 *The only breaking changes between these two versions are for experimental APIs.*
82
83 The main \`Theme\` export is now the default export as the component will soon be further paired down (separating out theme tokens, etc).
84
85 ${code`
86- import { Theme } from '@kalamazoo/theme';
87+ import Theme from '@kalamazoo/theme';
88 `}
89
90 The main \`Theme\` export is the global theme, like before, but does not contain sub-themes for components. Using it now requires you explicitly use the \`Consumer\` and \`Provider\` components on it.
91
92 ${code`
93import { Theme } from '@kalamazoo/theme';
94
95const Theme = createTheme();
96
97// Getting.
98- <Theme>{children}</Theme>
99+ <Theme.Consumer>{children}</Theme>
100
101// Setting.
102- <Theme values={theme} />
103+ <Theme.Provider value={theme} />
104 `}
105
106 The new APIs are not synonymous with the old ones as we've changed the approach to how themes are created and applied. For the new API, please refer to the docs.
107
108 ## 5.x - 6.x
109
110 *The only breaking changes between these two versions are for experimental APIs.*
111
112 The only experimental API that changed here is the \`Theme\` component. Themes are no longer components, but functions that return objects.
113
114 ### Theme shape
115
116 Before, you'd pass an object to the \`values\` prop. Now, you pass a function that returns an object.
117
118 ${code`
119import { Theme } from '@kalamazoo/theme';
120
121- const theme = {
122- mode: 'light'
123- }
124+ const theme = parentTheme => ({
125+ ...parentTheme,
126+ mode: 'light'
127+ });
128
129<Theme values={theme} />
130 `}
131
132 ### Component-specific theme functions
133
134 Component themes are no longer bound, passing in the parent theme. They're now just functions, however you define them, and they can get the parent theme from the execution context of the parent function.
135
136 ${code`
137import { Theme } from '@kalamazoo/theme';
138
139- const theme = {
140- badge({ appearance }, parentTheme) {
141- return { ... };
142- }
143- }
144+ const theme = parentTheme => ({
145+ badge({ appearance }) {
146+ return { ... }
147+ }
148+ });
149
150<Theme values={theme} />
151 `}
152`;