This project is a guide to quick learn to style in React with styled components. It also has an storybook to show all react components created.
You need to be comfortable writing ES6 JavaScript and CSS.
You need to have node
and npm
or yarn
installed on your computer.
you can either copy & paste this to your terminal
git clone https://github.com/Huespal/react-storybook && cd styling-in-react && yarn install && yarn start
or take the step by step route
git clone https://github.com/Huespal/react-storybook
cd styling-in-react
yarn install
yarn start
open the browser with the url http://localhost:3000
and you will be ready to start
- Refactor styles of src/components/Buttons/SocialButton.js component into styled-components
- We use
SocialButton
component in theNavbar
at the top as well as in theFooter
at the bottom however we would like to have different styling for each. Using template literals you can create a function within the styled-component and conditionally render different styles based on passed props. We would like to have icons with no outline in the Navbar and icons with outline in the Footer. - We would like the SocialButtons in the
Navbar
be a little smaller than the ones in theFooter
- pass the size of the button as a prop to your component.
- Create story for your
SocialButton
component - Create different states of your
SocialButton
component - one with outline and another without - Use knobs addon to be able to pass props to your component - add the functionality to your
SocialButton
story so we can change its size and icon within the Storybook.
- Add styled-components package to your project.
- Add Storybook to your project and configure it for your purposes.
Exercises solutions are in '-sol' name ended branches.
This material is available for private, non-commercial use under the GPL version 3.