مكتبة مكون JavaScript بواسطة Instacart
يرجى ملاحظة: ما زلنا في مرحلة ما قبل الإصدار. إذا اخترت استخدام الوجبات الخفيفة ، فيرجى الاستعداد لكسر التغييرات في المستقبل.
يمكنك استخدام إما yarn أو npm لتثبيت الوجبات الخفيفة وتبعياتها.
yarn add ' ic-snacks 'npm install ' ic-snacks 'الوجبات الخفيفة لديها عدد قليل من التبعيات الأقران اللازمة لاستخدام المكتبة.
إذا كان لديك بالفعل هذه المكتبات مدرجة في تبعيات التطبيق الخاص بك ، فلا داعي لتثبيتها مرة أخرى.
لمكتبة المكونات الرئيسية:
إذا كنت ترغب في استخدام الرسوم المتحركة: React-Ransition-Group V2.2
في بعض الأحيان ، قد يكون من المفيد العمل في هذا المشروع محليًا وعرض التغييرات في تطبيق آخر. يمكن تحقيق ذلك باستخدام رابط NPM
# From this directory
npm link
# go to the app you are working on
cd ../workspace/my_working_app
# symlink this app
npm link ic-snacksلعكس العملية ، يمكنك القيام بما يلي
# go to the app you are working on
cd ../workspace/my_working_app
# remove symlink
npm unlink ic-snacksyarn add @instacart/radium
yarn add prop-types
yarn add react
yarn add react-dom
yarn add react-transition-groupnpm install @instacart/radium
npm install prop-types
npm install react
npm install react-dom
npm install react-transition-groupباستخدام مكون:
import { CircleButton } from 'ic-snacks'
const MyComponent = props => {
const doYes = e => { alert ( 'Snacks are the best!' ) }
const doNo = e => { alert ( 'Wrong choice, choose again.' ) }
return (
< div >
< p > Do you love snacks? </ p >
< CircleButton onClick = { doYes } > Yes </ CircleButton >
< CircleButton onClick = { doNo } > No </ CircleButton >
</ div >
)
}مكون أكثر تعقيدًا:
import React , { Component } from 'react'
import { NavigationPills } from 'ic-snacks'
const choices = [
{ text : 'bananas' } ,
{ text : 'carrots' } ,
{ text : 'watermelon' } ,
{ text : 'snacks' } ,
{ text : 'kale' } ,
{ text : 'endives' } ,
{ text : 'arugula' } ,
{ text : 'spinach' } ,
{ text : 'potatoes' }
]
class Navigation extends Component {
static state = {
activePill : choices [ 0 ]
}
render ( ) {
return (
< div >
< NavigationPills
pills = { choices }
onPillClick = { ( e , choice ) => {
e . preventDefault ( ) ;
setState ( { activePill : choice . text } )
console . log ( 'Choice clicked!' , choice )
} }
label = 'Favorite healthy snack:'
activePill = { state . activePill }
/>
</ div >
)
}
} https://instacart.github.io/snacks/
يرجى الاطلاع على المستندات المساهمة