Skip to content

Commit

Permalink
remove the Gatsby flickering artifact by using PureComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Nov 23, 2018
1 parent 0597316 commit 1ad50f5
Show file tree
Hide file tree
Showing 93 changed files with 231 additions and 241 deletions.
12 changes: 7 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ jobs:
- ~/.cache/yarn

- run:
name: prepublish
name: Prepublish the ui-lib
command: yarn prepublish-ci

- run:
name: build
name: Build the portal
command: yarn build-ci

- run:
name: deploy
name: Deploy the portal
command: yarn deploy-ci

- run:
name: release on NPM
name: Release on NPM
command: yarn publish-ci

test:
Expand Down Expand Up @@ -74,10 +74,12 @@ workflows:
branches:
ignore:
- master
- /.*rc-.*|^rc\//
- /.*wip-.*|^wip\//
- gh-pages
- deploy:
filters:
branches:
only:
- master
- /rc-.*/
- /.*rc-.*|^rc\//
34 changes: 17 additions & 17 deletions packages/dnb-design-system-portal/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,9 @@ module.exports = {
},
plugins: [
'gatsby-plugin-sharp',
'gatsby-plugin-offline',
// 'gatsby-plugin-offline',
'gatsby-plugin-catch-links',
'gatsby-plugin-react-helmet',
'gatsby-plugin-emotion',
'gatsby-plugin-sass',
{
resolve: 'gatsby-plugin-postcss',
options: {
postCssPlugins: [
require('postcss-calc'),
require('postcss-custom-properties'),
require('postcss-preset-env')({ stage: 0 }),
require('autoprefixer')({
browsers: ['last 1 versions', 'explorer >= 11']
})
]
}
},
{
resolve: 'gatsby-mdx',
options: {
Expand All @@ -57,6 +42,21 @@ module.exports = {
path: `${__dirname}/src/pages`,
name: 'pages'
}
}
},
'gatsby-plugin-sass',
{
resolve: 'gatsby-plugin-postcss',
options: {
postCssPlugins: [
require('postcss-calc'),
require('postcss-custom-properties'),
require('postcss-preset-env')({ stage: 0 }),
require('autoprefixer')({
browsers: ['last 1 versions', 'explorer >= 11']
})
]
}
},
'gatsby-plugin-emotion'
]
}
2 changes: 1 addition & 1 deletion packages/dnb-design-system-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"fs-extra": "^7.0.1",
"gatsby": "^2.0.54",
"gatsby": "^2.0.55",
"gatsby-link": "^2.0.6",
"gatsby-mdx": "^0.2.0",
"gatsby-plugin-catch-links": "^2.0.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-design-system-portal/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const run = () => {
if (error) {
log.fail(`Failed to deploy! \n${error.message}`)
}
log.succeed(`Deployed successfully ${currentVersion}!`)
log.succeed(`Deployed successfully, version ${currentVersion}!`)
}
)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-design-system-portal/src/pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import styled from 'react-emotion'

export default class PageNotFound extends Component {
export default class PageNotFound extends PureComponent {
static propTypes = {
location: PropTypes.object.isRequired
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-design-system-portal/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component, Fragment } from 'react'
import React, { PureComponent, Fragment } from 'react'
import StickyMenuBar from '../shared/menu/StickyMenuBar'
import MainMenu from '../shared/menu/MainMenu'

Expand All @@ -12,7 +12,7 @@ import 'dnb-ui-lib/src/style/patterns' // import ony patterns
import 'dnb-ui-lib/src/style' // import both all components and the defualt theme

// react component
export default class App extends Component {
export default class App extends PureComponent {
render() {
return (
<Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import { css } from 'react-emotion'
import Head from 'react-helmet'
import dnb, {
Expand All @@ -29,7 +29,7 @@ const style = css`
background: white;
`

export default class ExampleAppPage extends Component {
export default class ExampleAppPage extends PureComponent {
componentDidMount() {
dnb.enableWebComponents()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { css } from 'react-emotion'
import { Modal } from 'dnb-ui-lib/src'
Expand Down Expand Up @@ -92,7 +92,7 @@ const style = css`
}
`

export default class LoanSausage extends Component {
export default class LoanSausage extends PureComponent {
static propTypes = {
equity: PropTypes.string.isRequired,
currency: PropTypes.string.isRequired,
Expand Down Expand Up @@ -167,7 +167,7 @@ export default class LoanSausage extends Component {
}
}

class SausageItem extends Component {
class SausageItem extends PureComponent {
static propTypes = {
title: PropTypes.string.isRequired,
percentage: PropTypes.string.isRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import { css } from 'react-emotion'
import Head from 'react-helmet'
import dnb, {
Expand All @@ -27,7 +27,7 @@ const style = css`
background: white;
`

export default class ExampleAppPage extends Component {
export default class ExampleAppPage extends PureComponent {
componentDidMount() {
dnb.enableWebComponents()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import Color from 'color'

export default class Table extends Component {
export default class Table extends PureComponent {
static propTypes = {
children: PropTypes.node.isRequired
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-design-system-portal/src/shared/menu/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import Link from 'gatsby-link'
import styled, { css, cx } from 'react-emotion'
Expand Down Expand Up @@ -91,7 +91,7 @@ const Box = styled.div`
flex-direction: column;
`

export default class Card extends Component {
export default class Card extends PureComponent {
static propTypes = {
url: PropTypes.string.isRequired,
customStyle: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-design-system-portal/src/shared/menu/MainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { injectGlobal, css } from 'react-emotion'
import classnames from 'classnames'
Expand Down Expand Up @@ -94,7 +94,7 @@ const toolbarStyle = css`
background-color: #fff;
`

export default class MainMenu extends Component {
export default class MainMenu extends PureComponent {
static propTypes = {
setAsOverlay: PropTypes.bool,
enableOverlay: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { StaticQuery, graphql } from 'gatsby'

import Link from '../parts/Link'
import PropTypes from 'prop-types'
import React from 'react'
import React, { PureComponent } from 'react'
import styled, { injectGlobal, cx } from 'react-emotion'

const showAlwaysMenuItems = [] // like "uilib" som someting like that

export default class SidebarLayout extends React.Component {
export default class SidebarLayout extends PureComponent {
static propTypes = {
location: PropTypes.object.isRequired,
showAll: PropTypes.bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { css, injectGlobal } from 'react-emotion'
// import Head from 'react-helmet'
import MainMenu from './MainMenu'
import gridSvg from '../../../static/assets/images/grid-32x32.svg'
import { FormLabel, Switch, Logo } from 'dnb-ui-lib/src'

export default class StickyMenuBar extends Component {
export default class StickyMenuBar extends PureComponent {
state = {
showOverlayMenu: false,
showGrid: null
Expand Down
4 changes: 2 additions & 2 deletions packages/dnb-design-system-portal/src/shared/parts/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dnb-ui-lib/src/style' // import both all components and the defualt them
// import 'dnb-ui-lib/src/style/themes/dnb-theme-open-banking.scss'

import { pageFocus } from 'dnb-ui-lib/src/shared/tools'
import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import { Link } from 'gatsby'

import PropTypes from 'prop-types'
Expand All @@ -19,7 +19,7 @@ import { markdownStyle } from './Markdown'
import styled, { cx } from 'react-emotion'
import { buildVersion } from '../../../package.json'

class Layout extends Component {
class Layout extends PureComponent {
static propTypes = {
children: PropTypes.node.isRequired,
location: PropTypes.object.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*
*/

import React, { Component, Fragment } from 'react'
import React, { PureComponent, Fragment } from 'react'

import PropTypes from 'prop-types'
import dnb from 'dnb-ui-lib/src'
import portalStyle from './PortalStyle'

// import { CodeRenderer } from './Code'
// import ReactMarkdown from 'react-markdown'
// export default class Markdown extends Component {
// export default class Markdown extends PureComponent {
// static propTypes = {
// children: PropTypes.string.isRequired
// }
Expand All @@ -35,7 +35,7 @@ import portalStyle from './PortalStyle'
// }
// }

export class Html extends Component {
export class Html extends PureComponent {
static propTypes = {
children: PropTypes.node,
value: PropTypes.string
Expand Down Expand Up @@ -79,7 +79,7 @@ export class Html extends Component {
}
}

// export class Script extends Component {
// export class Script extends PureComponent {
// static propTypes = {
// children: PropTypes.node,
// value: PropTypes.string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* List all the Icons available
*/

import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import * as PrimaryIcons from 'dnb-ui-lib/src/icons/primary_icons'
import * as SecondaryIcons from 'dnb-ui-lib/src/icons/secondary_icons'
import styled from 'react-emotion'

export default class Icons extends Component {
export default class Icons extends PureComponent {
state = { iconsToRender: [] }
static propTypes = {
type: PropTypes.string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import React, { Component, Fragment } from 'react'
import React, { PureComponent, Fragment } from 'react'

import Beautifier from './code_beautifier'
import PropTypes from 'prop-types'
Expand All @@ -15,7 +15,7 @@ import pretty from 'pretty' // https://www.npmjs.com/package/pretty
// import plugins from 'prettier/parser-parse5'
import CodeBlock from '../../inlineTags/CodeBlock'

export default class Code extends Component {
export default class Code extends PureComponent {
static propTypes = {
language: PropTypes.string,
raw: PropTypes.string,
Expand Down Expand Up @@ -94,7 +94,7 @@ export default class Code extends Component {
}
}

export class CodeRenderer extends Component {
export class CodeRenderer extends PureComponent {
static propTypes = {
language: PropTypes.string,
children: PropTypes.oneOfType([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Button, Tabs } from 'dnb-ui-lib/src'
import Code, { CodeRenderer } from './Code'
import React, { Component, Fragment } from 'react'
import React, { PureComponent, Fragment } from 'react'

import { CloseButton } from 'dnb-ui-lib/src/components/modal'
import Link from 'gatsby-link'
Expand Down Expand Up @@ -45,7 +45,7 @@ const tabsWrapperStyle = css`
}
`

class ComponentItemWrapper extends Component {
class ComponentItemWrapper extends PureComponent {
static propTypes = {
ExampleCode: PropTypes.string,
Description: PropTypes.func.isRequired,
Expand Down
Loading

0 comments on commit 1ad50f5

Please sign in to comment.