react lite ui
v1.0.1
關鍵功能•安裝•用法•文檔•演示
任何DOM元素都可以通過簡單的SASS文件自定義。 ?
您可以導入不影響應用程序捆綁包大小的各個組件。 ?
用最小的實施方式清潔設計,以宜人的UI減少了將代碼運送到您的應用程序的代碼。 ?
每個組件的重量輕 - 來自其他流行庫的組件(甚至更少!)的一半。 ?
npm install --save react-lite-ui
在您的App.js中:
import React from 'react' ;
import ReactDOM from 'react-dom' ;
import { Card } from 'react-lite-ui' ;
class App extends React . Component {
render ( ) {
return (
< Card
header = "Card header"
>
Card content
</ Card >
) ;
}
}
ReactDOM . render (
< App /> ,
document . getElementById ( 'root' )
) ;讓我們使用我們的App.js文件,然後在其中添加卡組件:
import React from 'react' ;
import ReactDOM from 'react-dom' ;
import { Card } from 'react-lite-ui' ;
class App extends React . Component {
render ( ) {
return (
< Card
header = "Am I Cute?"
footer = {
< Button href = "https://github.com/Codebrahma/react-lite-ui" type = "primary" bordered > view more </ Button >
}
elevation = "medium"
>
< div className = "col card-content" >
< img src = "https://placeimg.com/300/300/animals" alt = "animals" />
</ div >
</ Card >
) ;
}
}
ReactDOM . render (
< App /> ,
document . getElementById ( 'root' )
) ;創建一個名為theme.scss的文件:
:local( .card ) {
z-index : 2 ;
height : fit-content ;
width : 100 % ;
transition : margin 0.2 s ease-in-out ;
}
:local( .cardHeader ) {
color : #0c549c ;
text-align : center ;
}
:local( .cardFooter ) {
justify-content : center ;
align-self : baseline ;
}不用擔心這對您沒有意義。目前,我們將添加這些樣式,並將我們的樣式完整接線到卡組件。
現在,在我們的App.js文件中,我們將將theme支架傳遞給Card組件,例如:
import React from 'react' ;
import ReactDOM from 'react-dom' ;
import { Card } from 'react-lite-ui' ;
import theme from 'theme.scss' ; // Import the styles from theme.scss
class App extends React . Component {
render ( ) {
return (
< Card
theme = { theme } // Pass the theme as a prop to the card component here.
header = "Am I Cute?"
footer = {
< Button href = "https://github.com/Codebrahma/react-lite-ui" type = "primary" bordered > view more </ Button >
}
elevation = "medium"
>
< div className = "col card-content" >
< img src = "https://placeimg.com/300/300/animals" alt = "animals" />
</ div >
</ Card >
) ;
}
}
. . .因此,讓我們看一下我們在這裡所做的事情:
我們定義了自己的樣式,我們想使用card , cardHeader和cardFooter類自定義組件。
然後,我們將樣式通過theme Prop將組件傳遞給組件,該主題ProP應用於組件的結構。
然後,您通過的樣式與組件的默認樣式結合使用,以渲染您的自定義組件!有關如何自定義和各種道具的更多信息,您可以將其傳遞給組件,請訪問文檔頁面。
這就是您需要做的!這是我們的自定義卡組件:
很容易,對吧?想嘗試更多組件嗎?
只需在使用之前訪問我們的操場頁面即可嘗試組件,並與它們一起玩樂!
如果您想做出貢獻,請查看我們的貢獻指南並提出公關!我們會喜歡貢獻!
如果您發現問題或有疑問,請在此處打開一個問題,我們很樂意為您提供幫助,並繼續改善該圖書館! ?
謝謝!