Code Monkey home page Code Monkey logo

frontend-future's Introduction

This repo is no longer under development. Work has moved to https://github.com/guardian/guui.

guui

Build Status Coverage Status Known Vulnerabilities dependencies Status devDependencies Status

An investigation into the future architecture of theguardian.com.

#dotcom-future

Compilation

needs to be formalised still

Howtos

Use an SVG

Import the SVG as normal.

import MySVG from './my-svg.svg';

It will be loaded using frontend/ui/__tools__/svg-loader.js, which runs it through SVGO then returns it as a JSX object.

You can use the JSXified SVG as a normal JSX import:

<!-- my-svg.svg -->
<svg xmlns="http://www.w3.org/2000/svg" width="320" height="60"><path ... /></svg>
import MySVG from './my-svg.svg';

export default () => <div><MySVG /></div>;

// <div><svg width="320" height="60"><path ... /></svg></div>

Styling the SVG

It will also respond to an object on a block-styles prop:

<MySVG block-styles={{ red: { fill: "red" } }} />;

If a node in the original SVG has a data-block attribute, the loader will look for a key in the styles object that matches the value of data-block, and apply the styles inline:

<!-- my-svg.svg -->
<svg><path data-block="red" /></svg>
import MySVG from './my-svg.svg';

const styles = {
	red: { color: 'red' }
}

export default () => <MySVG block-styles={styles} />

// <svg><path data-block="red" style="color: red" /></svg>

You can use Sass in a similar way to non-SVG components:

<!-- my-svg.svg -->
<svg><path data-block="red" /></svg>
// styles.js.scss
red {
    fill: 'red'
}
import MySVG from './my-svg.svg';
import styles from './styles.js.scss';

export default () => <MySVG block-styles={styles} />

// <svg><path data-block="red" style="fill: red" /></svg>

frontend-future's People

Contributors

dominickendrick avatar gtrufitt avatar siadcock avatar sndrs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

gu-stav sndrs

frontend-future's Issues

Archive this repo

This repo should be archived, as it is no longer used, and replaced by dotcom-rendering

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.