Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chanjet-nova-theme

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chanjet-nova-theme

Chanjet nova ui theme provider

  • 0.0.33
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

chanjet-nova-theme

使用方法说明

实现支持 theme 的 React Component?

现在,我们以一个简单的支持 theme 的组件 InputGroup 来示范。InputGroup 是一个水平布局的组件,其中可以包含 IconInput,假设我们这里的 IconInput都已经实现了 theme 化管理,现在示例 InputGroup 如何实现 theme 的支持。

InputGroup.js


import React, {createElement} from 'react';
import classnames from 'classnames';
import {connectStyle} from 'chanjet-nova-ui-theme';

const InputGroup = props => {
    let {className, children, ...others} = props;
    // classnames 支持将多个 className 进行合并
    className = classnames[className];
    
    return (
        <div className={className} {...others}>
            {children}
        </div>
    )
}

InputGroup.propTypes = {
}

const StyledInputGroup = connectStyle('chanjet.ui.InputGroup')(StyledInputGroup);

export {
	StyledInputGroup as InputGroup
}

定义你的 ui theme

Theme.js

const theme = {
    // 组件样式声明,key 为 InputGroup.js 中 connectStyle 声明的名称。
    'chanjet.ui.InputGroup': {
        'chanjet.ui.Icon': {
            display:'inline-block',
            marginRight: '4px',
        },
        'chanjet.ui.Input': {
            display:'inline-block'
        },
        
        ‘.small': {
            height: '32px'
        },
        
        display:'inline-block',
        verticalAlign: 'middle'
    }
}

export default theme;

在你的App中使用

App.js

import React from 'react';
import {StyleProvider} from 'chanjet-nova-ui-theme';
import InputGroup from './InputGroup';
import Icon from './Icon';
import Input from './Input';
import theme from './Theme';

export default App extends React.Component {
    render() {
        return (
             <StyleProvider style={theme} mountNode='stylesheet'>
                <div>
                    <h1>It Works!</h1>
                    <InputGroup styleName="small">
	    	             <Icon name="ic_access_alarm" />
	    	             <Input type='number' />
    	             </InputGroup>
		           </div>
             </StyleProvider>
        )
    }
}

render(<App />, document.querySelector("#app"));

index.html


<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>React App</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
	<div id="app">Loading...</div>
</div>
<style id="stylesheet"></style>
</body>
</html>



FAQs

Package last updated on 29 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc