-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(onboard/updates): create changelog page (#467)
- Loading branch information
1 parent
1703d7d
commit e94db16
Showing
7 changed files
with
195 additions
and
2 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
64 changes: 64 additions & 0 deletions
64
packages/gatsby-theme-styleguide/src/gatsby-components/Changelog/Changelog.js
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,64 @@ | ||
import React from 'react' | ||
import styled, { css } from 'styled-components' | ||
import { StaticQuery, graphql } from 'gatsby' | ||
|
||
const ChangelogContainer = styled.div` | ||
h2 { | ||
margin-top: 2em; | ||
} | ||
h2, | ||
h3 { | ||
margin-bottom: 1em !important; | ||
} | ||
h3 { | ||
margin-top: 1.5em !important; | ||
line-height: 1; | ||
} | ||
` | ||
|
||
export const ChangelogItem = styled.div` | ||
${({ first }) => | ||
!first && | ||
css` | ||
font-size: 0.8rem; | ||
`} | ||
padding-bottom: 2em; | ||
border-bottom: solid 1px #c3c3c3; | ||
` | ||
|
||
const ChangelogComponent = ({ data }) => ( | ||
<ChangelogContainer> | ||
{data.allGithubRelease.edges | ||
.filter(release => release.node.descriptionHTML !== '') | ||
.map((release, i) => ( | ||
<ChangelogItem | ||
key={`release-${i}`} | ||
first={i === 0} | ||
dangerouslySetInnerHTML={{ __html: release.node.descriptionHTML }} | ||
/> | ||
))} | ||
</ChangelogContainer> | ||
) | ||
|
||
const query = graphql` | ||
query AllGitReleasesQuery2 { | ||
allGithubRelease { | ||
edges { | ||
node { | ||
descriptionHTML | ||
} | ||
} | ||
} | ||
} | ||
` | ||
|
||
const Changelog = () => ( | ||
<StaticQuery | ||
query={query} | ||
render={data => <ChangelogComponent data={data} />} | ||
/> | ||
) | ||
|
||
export default Changelog |
53 changes: 53 additions & 0 deletions
53
packages/gatsby-theme-styleguide/src/gatsby-components/Changelog/__tests__/Changelog.test.js
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,53 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import { StaticQuery } from 'gatsby' | ||
|
||
import Changelog, { ChangelogItem } from '../Changelog' | ||
|
||
const data = { | ||
allGithubRelease: { | ||
edges: [ | ||
{ | ||
node: { | ||
descriptionHTML: '<div>v1.0.1-alpha.31</div>', | ||
}, | ||
}, | ||
{ | ||
node: { | ||
descriptionHTML: '<div>v1.0.1-alpha.30</div>', | ||
}, | ||
}, | ||
{ | ||
node: { | ||
descriptionHTML: '', | ||
}, | ||
}, | ||
{ | ||
node: { | ||
descriptionHTML: '<div>v1.0.1-alpha.28</div>', | ||
}, | ||
}, | ||
{ | ||
node: { | ||
descriptionHTML: '<div>v1.0.1-alpha.26</div>', | ||
}, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
beforeEach(() => { | ||
StaticQuery.mockImplementationOnce(({ render }) => render(data)) | ||
}) | ||
|
||
describe('<Changelog />', () => { | ||
it('render corectly', () => { | ||
const tree = renderer.create(<Changelog />).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('do not render releases with empty descriptions', () => { | ||
const tree = renderer.create(<Changelog />) | ||
expect(tree.root.findAllByType(ChangelogItem).length).toEqual(4) | ||
}) | ||
}) |
65 changes: 65 additions & 0 deletions
65
...styleguide/src/gatsby-components/Changelog/__tests__/__snapshots__/Changelog.test.js.snap
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,65 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Changelog /> render corectly 1`] = ` | ||
.c0 h2 { | ||
margin-top: 2em; | ||
} | ||
.c0 h2, | ||
.c0 h3 { | ||
margin-bottom: 1em !important; | ||
} | ||
.c0 h3 { | ||
margin-top: 1.5em !important; | ||
line-height: 1; | ||
} | ||
.c1 { | ||
padding-bottom: 2em; | ||
border-bottom: solid 1px #c3c3c3; | ||
} | ||
.c2 { | ||
font-size: 0.8rem; | ||
padding-bottom: 2em; | ||
border-bottom: solid 1px #c3c3c3; | ||
} | ||
<div | ||
className="c0" | ||
> | ||
<div | ||
className="c1" | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "<div>v1.0.1-alpha.31</div>", | ||
} | ||
} | ||
/> | ||
<div | ||
className="c2" | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "<div>v1.0.1-alpha.30</div>", | ||
} | ||
} | ||
/> | ||
<div | ||
className="c2" | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "<div>v1.0.1-alpha.28</div>", | ||
} | ||
} | ||
/> | ||
<div | ||
className="c2" | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "<div>v1.0.1-alpha.26</div>", | ||
} | ||
} | ||
/> | ||
</div> | ||
`; |
1 change: 1 addition & 0 deletions
1
packages/gatsby-theme-styleguide/src/gatsby-components/Changelog/index.js
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 @@ | ||
export { default } from './Changelog' |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: 'Changelog' | ||
order: 2 | ||
--- | ||
|
||
import Changelog from '@mozaic-ds/gatsby-theme-styleguide/src/gatsby-components/Changelog' | ||
|
||
<Changelog /> |