Skip to content

Commit

Permalink
fix(wavedivider): render as an svg element to work in ie11
Browse files Browse the repository at this point in the history
- patch dependencies and remove unnecessary ones
- update echint to ignore styleguide build
- update rollup config using latest options
  • Loading branch information
theetrain committed Oct 6, 2017
1 parent c23939c commit 785b86e
Show file tree
Hide file tree
Showing 8 changed files with 628 additions and 165 deletions.
37 changes: 19 additions & 18 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,31 @@ import CssModulesSassLoader from './CssModulesSassLoader'

const cssExportMap = {}

const sassPreprocessor = (content, id) => new Promise((resolve) => {
const result = sass.renderSync({ file: id })
resolve({ code: result.css.toString() })
})
const sassPreprocessor = (content, id) =>
new Promise(resolve => {
const result = sass.renderSync({ file: id })
resolve({ code: result.css.toString() })
})

export default {
entry: path.resolve('./src/index.js'),
targets: [
{ format: 'cjs', dest: path.resolve('./dist/tds.cjs.js') },
{ format: 'es', dest: path.resolve('./dist/tds.es.js') }
input: path.resolve('./src/index.js'),
output: [
{ format: 'cjs', file: path.resolve('./dist/tds.cjs.js') },
{ format: 'es', file: path.resolve('./dist/tds.es.js') },
],
sourceMap: true,
sourcemap: true,

external: ['react', 'react-dom', 'prop-types'],

plugins: [
nodeResolve({
extensions: ['.js', '.jsx']
extensions: ['.js', '.jsx'],
}),
commonjs({
include: 'node_modules/**',
namedExports: {
'airbnb-prop-types': ['childrenOfType']
}
'airbnb-prop-types': ['childrenOfType'],
},
}),
postcss({
extract: path.resolve('./dist/tds.css'),
Expand All @@ -51,17 +52,17 @@ export default {
generateScopedName: 'TDS_[name]__[local]___[hash:base64:5]',
getJSON(id, exportTokens) {
cssExportMap[id] = exportTokens
}
})
},
}),
],
getExportNamed: false,
getExport(id) {
return cssExportMap[id]
}
},
}),
babel({
plugins: ['external-helpers'],
exclude: 'node_modules/**'
})
]
exclude: 'node_modules/**',
}),
],
}
31 changes: 13 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,22 @@
"license": "ISC",
"main": "dist/tds.cjs.js",
"module": "dist/tds.es.js",
"files": [
"dist",
"src",
"CHANGELOG.md",
"CONTRIBUTING.md",
"UPGRADING.md"
],
"files": ["dist", "src", "CHANGELOG.md", "CONTRIBUTING.md", "UPGRADING.md"],
"scripts": {
"build:css": "postcss --use cssnano --replace dist/tds.css",
"build:js": "rollup -c config/rollup.config.js",
"build:scss": "sh ./scripts/cp-scss.sh",
"build-package": "yarn build:js && yarn build:css && yarn build:scss",
"build-styleguide": "styleguidist build --config config/styleguide.config.js",
"build:package": "yarn build:js && yarn build:css && yarn build:scss",
"build:styleguide": "styleguidist build --config config/styleguide.config.js",
"deploy:docs": "node ./scripts/deploy-docs.js",
"deploy:package": "scripts/publish.sh",
"dev": "styleguidist server --config config/styleguide.config.js",
"lint:js": "eslint src config docs scripts --ext '.js,.jsx' --config config/.eslintrc.json --fix",
"lint:js":
"eslint src config docs scripts --ext '.js,.jsx' --config config/.eslintrc.json --fix",
"lint:scss": "stylelint 'src/components/**/*.scss' --config config/.stylelintrc.json",
"lint:ec": "echint",
"lint": "yarn lint:js && yarn lint:scss && yarn lint:ec",
"precommit": "yarn lint && yarn test && yarn build-package && yarn build-styleguide",
"precommit": "yarn lint && yarn test && yarn build:package && yarn build:styleguide",
"release:changelog": "changelog",
"release": "scripts/release.sh",
"scaffold": "node scripts/scaffold.js",
Expand Down Expand Up @@ -53,7 +48,6 @@
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
Expand All @@ -74,7 +68,7 @@
"eslint-plugin-jest": "^20.0.3",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "7.0.0",
"file-loader": "^0.11.2",
"file-loader": "^1.1.5",
"generate-changelog": "^1.3.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^20.0.4",
Expand All @@ -89,15 +83,15 @@
"react-styleguidist": "^5.5.9",
"react-test-renderer": "^16.0.0",
"react-transition-group": "^2.2.1",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-postcss": "^0.5.4",
"rollup-plugin-postcss": "^0.5.5",
"s3-website": "^3.1.2",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"stylelint": "^8.2.0",
"stylelint-config-css-modules": "^1.1.0",
"stylelint-config-standard": "^17.0.0",
"stylelint-scss": "^1.5.1",
Expand Down Expand Up @@ -132,7 +126,8 @@
"**.log",
"**/__snapshots__/**",
"docs/elements/**",
"icons/scripts/icons.js"
"icons/scripts/icons.js",
"styleguide/**"
]
}
}
177 changes: 175 additions & 2 deletions src/components/Dividers/WaveDivider/WaveDivider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,187 @@ import React from 'react'

import safeRest from '../../../utils/safeRest'

import wave from './wave.svg'
import styles from './WaveDivider.modules.scss'

/**
* Separate page content blocks.
*/
const WaveDivider = ({ ...rest }) => (
<img {...safeRest(rest)} src={wave} alt="" className={styles.wave} />
<svg
{...safeRest(rest)}
className={styles.wave}
xmlns="http://www.w3.org/2000/svg"
width="1202"
height="226"
viewBox="0 0 1202 226"
>
<defs>
<linearGradient
id="linear-gradient"

This comment has been minimized.

Copy link
@ryanoglesby08

ryanoglesby08 Oct 6, 2017

Contributor

One thing that worried me when I tried this was all of the hard-coded ids on all of these tags. So if there is more than one WaveDivider on the page, you will have multiple elements with the same ids. We say there should only be 1 wave per page, but still seems less than ideal.

Also, the id "linear-gradient" is super generic, so its more likely to conflict with something else. Maybe at least we should namespace all the ids used? So linear-gradient becomes wave-divider_linear-gradient?

This comment has been minimized.

Copy link
@theetrain

theetrain Oct 6, 2017

Author Contributor

The IDs thing is challenging without being able to dynamically generate IDs or CSS. More descriptive classnames on the way.

This comment has been minimized.

Copy link
@ryanoglesby08

ryanoglesby08 Oct 6, 2017

Contributor

Namespacing them seems easy though right? No need to dynamically generate that. Just add a prefix. At least that give a little more peace of mind.

x1="600"
y1="47.26"
x2="600"
y2="176.96"
gradientTransform="matrix(1, 0, 0, -1, 0, 227.8)"
gradientUnits="userSpaceOnUse"
>
<stop offset="0" stopColor="#fff" />
<stop offset="1" stopColor="#d8d8d8" />
</linearGradient>
<linearGradient
id="linear-gradient-2"
x1="600"
y1="224.7"
x2="600"
y2="70.2"
gradientTransform="matrix(1, 0, 0, -1, 0, 227.8)"
gradientUnits="userSpaceOnUse"
>
<stop offset="0.19" stopColor="#fff" />
<stop offset="1" stopColor="#d8d8d8" />
</linearGradient>
<linearGradient
id="linear-gradient-3"
x1="146.95"
y1="82.92"
x2="146.95"
y2="122.08"
xlinkHref="#linear-gradient"
/>
<linearGradient
id="linear-gradient-4"
x1="146.95"
y1="224.7"
x2="146.95"
y2="70.2"
xlinkHref="#linear-gradient-2"
/>
<linearGradient
id="linear-gradient-5"
x1="1076.11"
y1="102.31"
x2="1076.11"
y2="163.51"
xlinkHref="#linear-gradient"
/>
<linearGradient
id="linear-gradient-6"
x1="1128.83"
y1="213.27"
x2="1061.33"
y2="87.28"
xlinkHref="#linear-gradient-2"
/>
<linearGradient
id="linear-gradient-7"
x1="28.8"
y1="115"
x2="170.73"
y2="115"
gradientTransform="matrix(1, 0, 0, -1, 0, 228)"
gradientUnits="userSpaceOnUse"
>
<stop offset="0" stopColor="#fff" />
<stop offset="1" stopColor="#fff" stopOpacity="0" />
</linearGradient>
<linearGradient
id="linear-gradient-8"
x1="1185.42"
y1="113.95"
x2="1041.42"
y2="115.95"
xlinkHref="#linear-gradient-7"
/>
<linearGradient
id="linear-gradient-9"
x1="601"
y1="-2"
x2="601"
y2="52.08"
xlinkHref="#linear-gradient-7"
/>
<linearGradient
id="linear-gradient-10"
x1="600.78"
y1="222.98"
x2="600.78"
y2="160.94"
gradientTransform="matrix(1, 0, 0, 1, 0, 0)"
xlinkHref="#linear-gradient-7"
/>
<linearGradient
id="linear-gradient-11"
x1="601.22"
y1="64.89"
x2="601.22"
y2="2.85"
gradientTransform="translate(0.01 -0.21) rotate(0.02)"
xlinkHref="#linear-gradient-7"
/>
</defs>
<title>Artboard 1</title>

This comment has been minimized.

Copy link
@ryanoglesby08

ryanoglesby08 Oct 6, 2017

Contributor

We should either provide an accurate <title> and <description for the svg, or remove this element.

<g id="Layer_1" dataname="Layer 1">

This comment has been minimized.

Copy link
@ryanoglesby08

ryanoglesby08 Oct 6, 2017

Contributor

I think the ids on the <linearGradient>s are necessary because the class names reference them. But I don't think we need the ids on all of the <g> elements. Or the dataname. I think those are a result of the generated SVG from Sketch. We should remove those unnecessary attributes.

<g id="Layer_1-2" dataname="Layer 1">
<path
className={styles.cls1}
d="M293.89,144.8c24.26,1.32,47.12,2.06,67.8,2.06,193,0,395.64-56,590.52-67C886.68,66.05,821.57,56.1,769.84,56.1,614.41,56.1,452.32,117.3,293.89,144.8Z"
/>
<g className={styles.cls2}>
<path
className={styles.cls3}
d="M1200,146c-57.54-18-153.12-46.11-247.79-66.1-194.87,11.06-397.57,67-590.52,67-20.69,0-43.55-.74-67.8-2.06-46,8-91.66,13.16-136.77,13.16-42.2,0-100.58-6.26-157.12-14.1V224H1200Z"
/>
<g className={styles.cls4}>
<path d="M1200,146c-57.54-18-153.12-46.11-247.79-66.1-194.87,11.06-397.57,67-590.52,67-20.69,0-43.55-.74-67.8-2.06-46,8-91.66,13.16-136.77,13.16-42.2,0-100.58-6.26-157.12-14.1V224H1200Z" />
</g>
</g>
<path
className={styles.cls5}
d="M769.84,56.1c51.74,0,116.84,10,182.38,23.79C973.58,78.68,994.85,78,1016,78c49.13,0,118.77,11.47,184,25.06V0H0V114.49c90.58,12.22,202.25,25.38,293.89,30.31C452.32,117.3,614.41,56.1,769.84,56.1Z"
/>
<g className={styles.cls2}>
<path
className={styles.cls6}
d="M293.89,144.8C202.25,139.8,90.58,126.67,0,114.45V143.9C56.54,151.74,114.92,158,157.12,158,202.23,158,247.91,152.8,293.89,144.8Z"
/>
<g className={styles.cls4}>
<path d="M293.89,144.8C202.25,139.8,90.58,126.67,0,114.45V143.9C56.54,151.74,114.92,158,157.12,158,202.23,158,247.91,152.8,293.89,144.8Z" />
</g>
</g>
<path
className={styles.cls7}
d="M293.89,144.8C202.25,139.8,90.58,126.67,0,114.45V143.9C56.54,151.74,114.92,158,157.12,158,202.23,158,247.91,152.8,293.89,144.8Z"
/>
<g className={styles.cls2}>
<path
className={styles.cls8}
d="M952.21,79.89c94.67,20,190.24,48.11,247.79,66.1V103.05C1134.77,89.47,1065.13,78,1016,78,994.85,78,973.58,78.68,952.21,79.89Z"
/>
<g className={styles.cls4}>
<path d="M952.21,79.89c94.67,20,190.24,48.11,247.79,66.1V103.05C1134.77,89.47,1065.13,78,1016,78,994.85,78,973.58,78.68,952.21,79.89Z" />
</g>
</g>
<path
className={styles.cls9}
d="M952.21,79.89c94.67,20,190.24,48.11,247.79,66.1V103.05C1134.77,89.47,1065.13,78,1016,78,994.85,78,973.58,78.68,952.21,79.89Z"
/>
<rect className={styles.cls10} width="180" height="226" />
<rect className={styles.cls11} x="1020" width="180" height="226" />
<rect className={styles.cls12} y="154" width="1202" height="72" />
</g>
</g>
<g id="Layer_2" dataname="Layer 2">
<rect className={styles.cls13} y="158.3" width="1201.56" height="67.5" />
<rect
className={styles.cls14}
x="0.44"
y="0.21"
width="1201.56"
height="67.5"
transform="translate(1202.45 67.7) rotate(179.98)"
/>
</g>
</svg>
)

export default WaveDivider
Loading

0 comments on commit 785b86e

Please sign in to comment.