Skip to content

Commit 34e6467

Browse files
authored
Remove defining the DefaultTheme from library DTS (#829)
* Remove defining the DefaultTheme from library DTS
1 parent 2df5d8c commit 34e6467

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed
File renamed without changes.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Changed
1717

18+
- Update tsconfig to include packages under `./@types` and `node_modules/@types` in the TypeScript compilation.
19+
- Move the definition of default theme from its implementation to its `d.ts` file under `./@types` to support [function themes](https://styled-components.com/docs/advanced#function-themes) usage of styled-component.
20+
1821
### Fixed
1922

2023
## [3.2.0] - 2022-04-11

src/theme/default.ts

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { Breakpoints } from './styled';
5-
64
export const fonts = {
75
body: "'Ember', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;",
86
monospace: 'Menlo, monospace',
@@ -21,19 +19,34 @@ export const zIndex = {
2119
notificationGroup: 40,
2220
};
2321

24-
const breakpoints = [
25-
'20rem', // 320px
26-
'35.5rem', // 568px
27-
'48rem', // 768px
28-
'64rem', // 1024px
29-
'90rem', // 1440px
30-
] as Breakpoints;
31-
32-
breakpoints.xs = breakpoints[0];
33-
breakpoints.sm = breakpoints[1];
34-
breakpoints.md = breakpoints[2];
35-
breakpoints.lg = breakpoints[3];
36-
breakpoints.xl = breakpoints[4];
22+
enum BreakpointEnum {
23+
xs = 'xs',
24+
sm = 'sm',
25+
md = 'md',
26+
lg = 'lg',
27+
xl = 'xl',
28+
}
29+
30+
const breakpointValues = {
31+
[BreakpointEnum.xs]: '20rem', // 320px phone
32+
[BreakpointEnum.sm]: '35.5rem', // 568px tablet
33+
[BreakpointEnum.md]: '48rem', // 768px small laptop
34+
[BreakpointEnum.lg]: '64rem', // 1024px desktop
35+
[BreakpointEnum.xl]: '90rem', // 1440px large screen
36+
};
37+
38+
const breakpointAliaseValues = {
39+
[0]: breakpointValues[BreakpointEnum.xs],
40+
[1]: breakpointValues[BreakpointEnum.sm],
41+
[2]: breakpointValues[BreakpointEnum.md],
42+
[3]: breakpointValues[BreakpointEnum.lg],
43+
[4]: breakpointValues[BreakpointEnum.xl],
44+
};
45+
46+
const breakpoints = {
47+
...breakpointValues,
48+
...breakpointAliaseValues,
49+
};
3750

3851
const mediaQueries = {
3952
min: {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"experimentalDecorators": true,
2121
"emitDecoratorMetadata": true,
2222
"esModuleInterop": true,
23+
"typeRoots": ["./@types", "node_modules/@types"]
2324
},
2425
"include": ["src/**/*", "tst/**/*", "jest-snapshot.config.js", "jest.config.js"],
2526
"exclude": [

0 commit comments

Comments
 (0)