Coder Social home page Coder Social logo

jsdelivrbot / menu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from one-react/menu

0.0 1.0 0.0 1000 KB

A collection of cosmetic๐Ÿ’„, light-lux ๐Ÿ‘œ๐Ÿ’ UI components written with React.

Home Page: https://one-react.github.io/menu

License: MIT License

JavaScript 17.41% TypeScript 73.57% CSS 9.02%

menu's Introduction

One React Component: menu

logo

TravisCI Build CircieCI Build Coverage Version Chat License: MIT JavaScript Style Guide Greenkeeper badge

Installation

// with npm
npm install or-menu

// with yarn
yarn add or-menu

Usage

  • Config webpack sass-loader if you are using webpack.
// webpack.config.js
{
  test: /\.scss$/,
  use: [
    'style-loader',
    'css-loader',
    'sass-loader'
  ],
  include: [
    /node_modules\/or\-\w+/ //include or-components
  ]
}

Basic Example

import { Menu, MenuItem } from 'or-menu'
import React, { PureComponent } from 'react'

export default class Example extends PureComponent<{}, {}> {
  render() {
    return (
      <div className="example-wrapper">
        <Menu>
          <MenuItem subNav={subNav1}>MAKEUP</MenuItem>
          <MenuItem subNav={subNav2}>PERFUME</MenuItem>
          <MenuItem subNav={subNav1}>MAKEUP</MenuItem>
          <MenuItem subNav={subNav2}>CLOTHING</MenuItem>
          <MenuItem>NO-SUBNAV</MenuItem>
        </Menu>
      </div>
    )
  }
}

const subNav1 = (
  <div className="sub-nav-overlay">
    <div className="item-wrapper">
      <div className="title">FACE</div>
      <div>New Arrivals</div>
      <div>Foundation</div>
      <div>Concealer</div>
      <div>Blush</div>
      <div>Powder</div>
      <div>Primer</div>
    </div>
    <div className="item-wrapper">
      <div className="title">LIP</div>
      <div>Lipstick</div>
      <div>Liquid Lipcolor</div>
      <div>Lip Gloss</div>
      <div>Lip Pencil</div>
      <div>Matte Finish</div>
    </div>
    <div className="item-wrapper">
      <div className="title">COLLECTIONS</div>
      <div>New Arrivals</div>
      <div>Pure Color</div>
      <div>Poppy</div>
      <div>Suger</div>
      <div>Sunset Collection</div>
    </div>
    <div className="item-wrapper">
      <div
        className="image"
        style={{ backgroundImage: `url(${require('./images/face.png')})` }}
      />
    </div>
  </div>
)

const subNav2 = (
  <div className="sub-nav-overlay">
    <div className="item-wrapper">
      <div className="title">MEN</div>
      <div>Wood Sage & Sea Salt</div>
      <div>Orris & Sandalwood</div>
      <div>Lime Basil & Mandarin</div>
      <div>Amber & Lavender</div>
      <div>Pomegranate Noir</div>
    </div>
    <div className="item-wrapper">
      <div className="title">WOMEN</div>
      <div>English Pear</div>
      <div>Lime Basil</div>
      <div>Honeysuckle & Davana </div>
      <div>Red Roses</div>
      <div>Wild Bluebel</div>
    </div>
    <div className="item-wrapper">
      <div className="title">GIFTS</div>
      <div>Home Candle</div>
      <div>Deluxe Candle</div>
      <div>Cologne</div>
      <div>Grapefruit Candle</div>
    </div>
    <div className="item-wrapper">
      <div
        className="image"
        style={{ backgroundImage: `url(${require('./images/perfume.png')})` }}
      />
    </div>
  </div>
)

API

MenuItem:

interface Props {
  /**
   * additional className for menuItem
   */
  className?: string

  /**
   * menuItem title
   */
  children: string

  /**
   * the sub-nav appears when the mouse moves over the menuItem title
   */
  subNav?: React.ReactElement<any>
}

Menu:

interface Props {
  /**
   * additional className for menu
   */
  className?: string
}

Customize Theme

Customize in webpack

The following variables in or-menu can be overridden:

$or-menu-active-color: or-$gray8 !default;

$or-menu-border-width: $or-border-width !default;
...

For more variables, see here.

Alternatively, you can override variables from or-theme to keep all or-components in a unified theme style.

First you should create a theme.scss file to declare the variables you want to override.

Then use the data option provided by sass-loader to override the default values of the variables.

We take a typical webpack.config.js file as example to customize it's sass-loader options.

// webpack.config.js
{
  test: /\.scss$/,
  use: [
    'style-loader',
    'css-loader',
    {
      loader: 'sass-loader',
      options: {
        data: fs.readFileSync(path.resolve(__dirname, 'theme.scss')) // pass theme.scss to sass-loader
      }
    }
  ],
  include: [
    /node_modules\/or\-\w+/ //include or-components
  ]
}

Demos and Docs

powered by storybook

Click Here

License

MIT ยฉ foryuki

menu's People

Contributors

foryuki avatar greenkeeper[bot] avatar jsdelivrbot avatar

Watchers

 avatar

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.