-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add normalization for body and html & fix emotion leak (#1515)
- Loading branch information
Showing
7 changed files
with
118 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@marigold/components": patch | ||
"@marigold/system": patch | ||
--- | ||
|
||
feat: add normalization for body and html & fix emotion leak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { useTheme, ThemeProvider } from '@marigold/system'; | ||
export * from './MarigoldProvider'; | ||
export { SSRProvider } from '@react-aria/ssr'; | ||
|
||
export * from './MarigoldProvider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { ThemeProvider } from './useTheme'; | ||
|
||
import { Global } from './Global'; | ||
|
||
test('applies normlaization to html and body', () => { | ||
const root = render(<Global />); | ||
|
||
const html = window.getComputedStyle(root.baseElement.parentElement!); | ||
expect(html.height).toBe('100%'); | ||
const body = window.getComputedStyle(root.baseElement); | ||
expect(body.height).toBe('100%'); | ||
expect(body.lineHeight).toBe('1.5'); | ||
}); | ||
|
||
test('applies global styles for body and html based on `theme.root`', () => { | ||
const theme = { | ||
colors: { | ||
background: '#fff', | ||
}, | ||
fonts: { | ||
body: 'Inter', | ||
}, | ||
lineHeights: { | ||
body: 2.5, | ||
}, | ||
fontWeights: { | ||
body: 500, | ||
html: 700, | ||
}, | ||
root: { | ||
body: { | ||
fontFamily: 'body', | ||
lineHeight: 'body', | ||
fontWeight: 'body', | ||
}, | ||
html: { | ||
bg: 'background', | ||
}, | ||
}, | ||
}; | ||
|
||
const root = render( | ||
<ThemeProvider theme={theme}> | ||
<Global /> | ||
</ThemeProvider> | ||
); | ||
|
||
const html = root.baseElement.parentElement; | ||
expect(html).toHaveStyle(`background: ${theme.colors.background}`); | ||
|
||
const body = root.baseElement; | ||
expect(body).toHaveStyle(`font-family: ${theme.fonts.body}`); | ||
expect(body).toHaveStyle(`line-height: ${theme.lineHeights.body}`); | ||
expect(body).toHaveStyle(`font-weight: ${theme.fontWeights.body}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './Element'; | ||
export * from './Global'; | ||
export * from './types'; | ||
export * from './useTheme'; |