Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ui: add a way to write combinator selectors #17761

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/app/rendering/core/JavascriptRendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ trait JavascriptRendering extends Logging {
private def prescript: ByteArrayInputStream = {
val pre =
"""
|var global = global || this, self = self || this, window = window || this;
|var global = global || this, self = self || this;
|
|var console = {};
|
Expand Down
1 change: 1 addition & 0 deletions ui/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
["babel-plugin-transform-runtime", {
"polyfill": false
}],
"styled-jsx/babel",
["babel-plugin-transform-react-jsx", {
"pragma": "h"
}]
Expand Down
4 changes: 4 additions & 0 deletions ui/__config__/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const config = {
'node_modules', // default location, but we're overiding above, so it needs to be explicit
],
extensions: ['.js', '.jsx'],
alias: {
// some libs expect react, this stops them bundling it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

react: 'preact',
},
},
resolveLoader: { modules: [path.resolve(ui, '__tools__'), 'node_modules'] },
watchOptions: { ignored: /node_modules/ },
Expand Down
19 changes: 1 addition & 18 deletions ui/__tools__/svg-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,7 @@ module.exports = function loadSVG(source) {
`export default props => {
const svg = ${converter.convert(result.data)};

function setStyle(node, style) {
node.attributes.style = Object.assign({}, node.attributes.style, style);
}

function setBlockStyles(node) {
const style = props['block-styles'][node.attributes['data-block']];
if (style) setStyle(node, style);
node.children.forEach(setBlockStyles);
}

if (props.className) {
if (svg.attributes['class']) {
svg.attributes['class'] += props.className;
} else {
svg.attributes['class'] = props.className;
}
}
if (props['block-styles']) setBlockStyles(svg);
Object.assign(svg.attributes, props);

return svg;
}
Expand Down
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"preact-svg-loader": "^0.2.0",
"prettier": "^1.5.3",
"sass-loader": "^6.0.6",
"styled-jsx": "^1.0.10",
"stylelint-config-standard": "^17.0.0",
"stylelint-order": "^0.6.0",
"stylelint-scss": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions ui/src/assets/images/guardian-logo-320.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ui/src/components/head/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import resetCSS from './reset.css';
import fontsCSS from './fonts.css';

export default (props: any, css: string) =>
export default (props: any, css: Array<string>) =>
`<head lang="en" data-page-path="/uk">
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
Expand All @@ -19,5 +19,5 @@ export default (props: any, css: string) =>
<link rel="stylesheet" href="${props.fontsUrl}">
<style>${resetCSS}</style>
<style>${fontsCSS}</style>
${css}
${css.join('\n')}
</head>`;
6 changes: 5 additions & 1 deletion ui/src/index.server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { render as renderToString } from 'preact-render-to-string';
import { StyletronProvider } from 'styletron-preact';
import StyletronServer from 'styletron-server';
import { flushToHTML as getStyledJSXStylesheetsHtml } from 'styled-jsx/server';

import head from 'components/head';
import Body from 'components/body';
Expand All @@ -26,7 +27,10 @@ export const render = (props: Object) => {
return `
<!DOCTYPE html>
<html lang="en">
${head(props, styletron.getStylesheetsHtml())}
${head(props, [
styletron.getStylesheetsHtml(),
getStyledJSXStylesheetsHtml(),
])}
${body}
</html>
`.trim();
Expand Down
17 changes: 10 additions & 7 deletions ui/src/views/404/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ import {
logo,
} from './style.js.scss';

export default ({ beaconUrl }: Object) => (
export default ({ beaconUrl }: Object) =>
<div style={fluidWrap}>
<div style={topBar}>
<a href="/" style={topBarLink}>
Home
</a>
</div>
<Logo
block-styles={{ guardian: { fill: colour.brandBlueDark } }}
style={logo}
/>
<div>
<Logo style={logo} />
<style jsx>{`
div :global(.guardian) {
fill: ${colour.brandBlueDark};
}
`}</style>
</div>
<h1 style={heading}>
Sorry - we haven’t been able to serve the page you asked for.
</h1>
Expand Down Expand Up @@ -80,5 +84,4 @@ export default ({ beaconUrl }: Object) => (
style={{ display: 'none' }}
rel="nofollow"
/>
</div>
);
</div>;
Loading