GithubHelp home page GithubHelp logo

canonical-web-and-design / vanilla-framework-react Goto Github PK

View Code? Open in Web Editor NEW
19.0 7.0 15.0 1.3 MB

An implementation of Vanilla Framework using React

HTML 0.04% JavaScript 93.54% Shell 6.42%
react scss pattern-library vanilla-framework

vanilla-framework-react's Introduction

Archived

Ths project has been archived for the time being, as it's not currently being maintained or actively used.


Vanilla Framework (in React)

This is a simple implementation of Vanilla Framework using React.

Storybook | Vanilla Framework

Quick start

To get up and running with Vanilla Framework React quickly, add the create-react-app CLI tool to your machine. Then, run the following code:

create-react-app my-app
cd my-app/
yarn add vanilla-framework vanilla-framework-react node-sass-chokidar
export SASS_PATH=`pwd`/node_modules:${SASS_PATH}

Open package.json and add the following scripts:

"build-css": "node-sass-chokidar src/ -o public/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o public/ --watch --recursive",

Open public/index.html and add the line:

<link rel="stylesheet" href="styles.css" />

Create src/styles.scss with the following code:

// Optionally override some settings
$color-brand: #fb3b00;

// Import the theme
@import 'vanilla-framework/scss/build';

// Include the Sass you want
@include vanilla;

Remove the following line from src/index.js:

import './index.css';

Now open a terminal and run yarn watch-css and open another terminal and run yarn start.

In your src/App.js file you can now include Vanilla Framework React components by adding the code:

import React, { Component } from 'react';
import { Button } from 'vanilla-framework-react';

class App extends Component {
  render() {
    return (
      <div>
        <Button brand value="Custom VF React Button!" />
      </div>
    );
  }
}

export default App;

Including Vanilla in your React project

This component library requires Vanilla Framework to function. You can either hotlink the latest build directly into your markup, like so (replace x's with the version you want):

<link rel="stylesheet" href="https://assets.ubuntu.com/v1/vanilla-framework-version-x.x.x.min.css" />

Or you can add Vanilla Framework to your node_modules folder and save it into your project's dependencies using your favourite package manager. You should also ensure that your Sass builder is including modules from node_modules. For example:

yarn add vanilla-framework
export SASS_PATH=`pwd`/node_modules:${SASS_PATH}

Then reference it from your own Sass files, with optional settings:

// Optionally override some settings
$color-brand: #fb3b00;

// Import the theme
@import 'vanilla-framework/scss/build';

// Include the Sass you want
@include vanilla;

If you don't want the whole framework, you can just @include specific parts - e.g. @include vf-b-forms.

Local development

In the project directory, you can run:

./run

This will start up an interactive development & testing environment listing all components.

The page will reload if you make edits.
You will also see any lint errors in the console.

./run test

Launches the test runner in the interactive watch mode.

./run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

vanilla-framework-react's People

Contributors

anthonydillon avatar barrymcgee avatar caleb-ellis avatar grahambancroft avatar renovate-bot avatar steverydz avatar willmoggridge avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vanilla-framework-react's Issues

Compile component SCSS separately?

To help with packaging components as individual pieces have you considered compiling separately?

There's been talk of making the patterns mix-and-match so why not do the same with the React components.

A component file structure could be like:

components/ 
    Button/
        Button.js
        Button.scss
        Button.css
  • Button.js would import './Button.css'.
  • Button.css would contain the compiled code for Button.scss.
  • Btutton.scss would be @import 'vanilla-framework/scss/_patterns_buttons.scss'.

It seems convoluted, and maybe a better way would be to automate the compilation to each folder (removing the need for Button.scss). Or maybe an even better way would be not to do this at all.

Just an idea, and open to discussion/ being shot down.

Add padding to Storybook's content

In Storybook, components show against the sidebar with no padding.
Matrix stands out as one which has this problem.

One option to tackle this is to import a stylesheet into .storybook/config.js and add padding. This can be done simply by adding `import './storybook.scss'.
I believe the layout of the page can also be tweaked in config.

Screenshot

selection_015

Accordion and AccordionItem logic

I wouldn't expect AccordionItem to manage it's own state as implementing a true single-item-open accordion requires the state of all items to be known.

I'd expect Accordion to pass it's own methods for manipulating it's children to the AccordionItem's for onclick handlers etc. This would make the Accordion component a more generic wrapper.

When I'm back at work next week I'll better explain what I mean in comment.

Combine button into a single component

Buttons are looking good. Have you thought of creating a single button component with a prop of type [brand, positive, negative]?

This would make the component more DRY.

Add Link component

Subtypes:

  • External link
  • Strong link
  • Soft link
  • Inverted link
  • Back to top link

Add List component

  • Simple list
  • List with icon
  • List with dividers
  • List with icons and dividers
  • Inline list
  • Middot-seperated inline list
  • Split list

Add Strip component

Subtypes:

  • Strip accent
  • Strip image
  • Strip is-bordered
  • Strip is-deep
  • Strip is-shallow

Set up enzyme testing environment

At the moment, all the testing is done via Jest's snapshot comparison tool. This is okay for pure UI components, but it is not adequate for components with internal logic/state (e.g. accordion, table).

Eslint throwing fatal error over variable declaration

Can't qyuite figure this out

  1. Pull code
  2. Run npm run lint
  3. The following "fatal" error is thrown:

screen shot 2017-10-11 at 16 16 53

4 ..which points to this line โ†’ https://github.com/vanilla-framework/vanilla-components/blob/master/src/App.js#L10

Why is this not valid? ๐Ÿค”

Make tests pass

Currently, tests fail. If I run npm run test and then press a, I get:

 FAIL  src/components/App/App.test.js
  โ— Test suite failed to run

    Cannot find module './App.css' from 'App.js'
      
      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (src/components/App/App.js:5:76)

 FAIL  src/components/Button/Button.test.js
  โ— Test suite failed to run

    Cannot find module './Button.css' from 'Button.js'
      
      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (src/components/Button/Button.js:3:1)

 FAIL  src/components/Card/Card.test.js
  โ— Test suite failed to run

    Cannot find module './Card.css' from 'Card.js'
      
      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (src/components/Card/Card.js:3:1)

Test Suites: 3 failed, 3 total
Tests:       0 total
Snapshots:   0 total
Time:        1.384s
Ran all test suites.

Watch Usage: Press w to show more.

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.