Skip to content

Commit

Permalink
refactor: set global css variable for font size
Browse files Browse the repository at this point in the history
implement #11
  • Loading branch information
KOREAN139 committed Dec 30, 2020
1 parent e875bcf commit 74b0831
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
</script>

<style>
:root {
--header-height: 120px;
--font-size-xlarge: 64px;
--font-size-large: 48px;
--font-size-regular: 24px;
--font-size-small: 14px;
--font-weight-bold: 700;
--font-weight-light: 300;
}
main {
text-align: center;
padding: 1em;
Expand Down
9 changes: 5 additions & 4 deletions src/container/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
.container {
width: 100%;
height: var(--header-height);
display: flex;
justify-content: space-between;
text-align: center;
}
.title {
font-size: 64px;
font-weight: 700;
font-size: var(--font-size-xlarge);
font-weight: var(--font-weight-bold);
margin: auto 0;
}
.search,
.settings {
font-size: 24px;
font-weight: 300;
font-size: var(--font-size-regular);
font-weight: var(--font-weight-light);
color: rgba(0, 0, 0, 0.3);
margin: auto 0;
}
Expand Down
14 changes: 7 additions & 7 deletions test/container/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ describe('Render Header', () => {
expect(title.nextElementSibling).toEqual(settings);
});

it('should render title w/ 64px bold, others w/ 24px light', async () => {
it('should render title w/ xlarge bold, others w/ regular light', async () => {
const { getByTestId } = render(Header);

const title = getByTestId('title');
const search = getByTestId('search');
const settings = getByTestId('settings');

expect(title).toHaveStyle({
'font-size': '64px',
'font-weight': 700,
'font-size': 'var(--font-size-xlarge)',
'font-weight': 'var(--font-weight-bold)',
});
expect(search).toHaveStyle({
'font-size': '24px',
'font-weight': 300,
'font-size': 'var(--font-size-regular)',
'font-weight': 'var(--font-weight-light)',
});
expect(settings).toHaveStyle({
'font-size': '24px',
'font-weight': 300,
'font-size': 'var(--font-size-regular)',
'font-weight': 'var(--font-weight-light)',
});
});

Expand Down

0 comments on commit 74b0831

Please sign in to comment.