Git Product home page Git Product logo

dynamic-antd-theme's Introduction

Dynamic change Ant-Design theme by simply method. It is a general solution, whether you are less/scss/css.

English | ็ฎ€ไฝ“ไธญๆ–‡

Deploy Status

๐Ÿ  HomePage

Dynamic-Antd-Theme-Demo

๐ŸŒ Browser Support

Chrome Edge Firefox IE Safari
Chrome 39.0+ โœ” Edge 12.0+ โœ” Firefox 30.0+ โœ” IE 11+ โœ” Safari 9.1+ โœ”

๐Ÿ“ฆ Install

npm install dynamic-antd-theme or yarn add dynamic-antd-theme

๐Ÿ”จ Usage

The best usage of the dynamic-antd-theme is in the common compnent (Layout/Header etc...) of your application.

// Layout.js
...
import DynamicAntdTheme from 'dynamic-antd-theme';
...

<div className='theme-container'>
  <span>Change antd theme: </span>
  <DynamicAntdTheme />
</div>

More Example


<DynamicAntdTheme primaryColor='#77dd66' />

<DynamicAntdTheme storageName='my-custom-define-color' />

<DynamicAntdTheme style={{ display: 'margin: 10px' }} />

function themeChangeCallback (color) {
  document.getElementById('my-header-bar').style.backgroundColor = color;
}

<DynamicAntdTheme themeChangeCallback={this.themeChangeCallback} />

โœจ Props

Props Type Default Description
primaryColor String #1890d5 your antd initial @primary-color
storageName String custom-antd-primary-color the name that is saved in the localStorage
style Object null you can custom the component style simply
placement String bottomRight change the color-picker position, bottom, bottomRight, right, topRight, top, topLeft, left, bottomLeft
themeChangeCallback Func null you can do something use themeColor when themeColor changed.

๐ŸŒž Export

export Description
default The component
getThemeColor param: color, generate colorObj based on color
changeAntdTheme param: colorObj, change the antd theme

Example

import { getThemeColor, changeAntdTheme } from 'dynamic-antd-theme';
...

<Button
  onClick={
    () => {
      const color = 'blue';
      changeAntdTheme(
        getThemeColor(color);
      );
    }
  }
>Change Theme</Button>

โš ๏ธ Attention

This solution is easy to use, so it is prone to problems. We hope you can give us timely feedback. For example, if there is a problem with any component, we will fix the updated version as soon as possible.

  • The current version requires your antd version to be lower than v3.19.0

The antd version is higher than v3.19.0 you can also use it, if have some problems remember give me an issue.

  • ...Plugin versions are updated from time to time based on antd (new antd components are updated)

๐Ÿ”— Changelogs

  • v0.1.3

    Fix the Slider Component.

  • v0.1.4

    Fix repeat insert <style> tag.

  • v0.1.5

    Add placement props, bottom, bottomRight, right, topRight, top, topLeft, left, bottomLeft. Default is bottomRight.

  • v0.1.6

    Add themeChangeCallback props, you can do something use themeColor when themeColor changed.

  • v0.2.0

    Fix ant-design table tr background when cursor hovered.

  • v0.2.4

    Support IE 11+.

  • v0.2.6

    Fix DatePicker current date color.

  • v0.3.0

    Export { getThemeColor, changeAntdTheme } methods to help the developer who don't need react-colorPicker

  • v0.3.2

    Fix <Button type='danger' /> bug, when hover the font color is primary-color.

dynamic-antd-theme's People

Contributors

luffyzh avatar dependabot[bot] avatar

Watchers

James Cloos 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.