-
-
Notifications
You must be signed in to change notification settings - Fork 76
practice-react-styling-done #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ const Task02 = () => { | |
| <RBButton variant="primary" size="lg">Button!</RBButton> | ||
| </Col> | ||
| <Col> | ||
| Button! | ||
| <Button variant="primary" size="lg" active>Button!</Button> | ||
| <Button variant="secondary" size="sm" disabled>Button!</Button> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| </Col> | ||
| </Row> | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import React from 'react'; | ||
|
|
||
| import Breadcrumb from '../src/components/Breadcrumb/Breadcrumb'; | ||
| import { Row, Col, Breadcrumb as RBBreadcrumb } from 'react-bootstrap'; | ||
|
|
||
| const Task03 = () => { | ||
|
|
@@ -15,7 +15,11 @@ const Task03 = () => { | |
| </RBBreadcrumb> | ||
| </Col> | ||
| <Col> | ||
| Breadcrumb! | ||
| <Breadcrumb> | ||
| <Breadcrumb.Item href='#'>Home</Breadcrumb.Item> | ||
| <Breadcrumb.Item href="https://getbootstrap.com/docs/4.0/components/breadcrumb/">Library</Breadcrumb.Item> | ||
| <Breadcrumb.Item active>Data</Breadcrumb.Item> | ||
| </Breadcrumb> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| </Col> | ||
| </Row> | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,50 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Row, Col, Tabs as RBTabs, Tab as RBTab, } from 'react-bootstrap'; | ||
| import Tabs from "./../src/components/Tabs"; | ||
| import Tab from "./../src/components/Tab"; | ||
| import { Row, Col, Tabs as RBTabs, Tab as RBTab } from "react-bootstrap"; | ||
|
|
||
| const Task04 = () => { | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBTabs defaultActiveKey="profile" id="uncontrolled-tab-example"> | ||
| <RBTab eventKey="home" title="Home"> | ||
| <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur condimentum lacus nec ligula faucibus rhoncus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; </p> | ||
| </RBTab> | ||
| <RBTab eventKey="profile" title="Profile"> | ||
| <p>Donec dignissim ultricies felis, eu dictum eros congue in. In gravida lobortis libero nec tempus. Cras rutrum nisl ut leo volutpat rhoncus. Nulla massa nulla, viverra hendrerit laoreet at, tincidunt eu lacus.</p> | ||
| </RBTab> | ||
| <RBTab eventKey="contact" title="Contact" disabled> | ||
| <p>Vivamus metus nulla, fermentum eget placerat vitae, mollis interdum elit. Pellentesque arcu augue, vulputate ut porttitor ut, suscipit non orci. Integer justo odio, suscipit eget tortor nec, molestie lobortis eros. Nullam commodo elit sit amet lacus blandit aliquet. Mauris at nibh eget nisl pulvinar dignissim.</p> | ||
| </RBTab> | ||
| </RBTabs> | ||
| </Col> | ||
| <Col> | ||
| Tabs! | ||
| </Col> | ||
| </Row> | ||
| ) | ||
| } | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBTabs defaultActiveKey="profile" id="uncontrolled-tab-example"> | ||
| <RBTab eventKey="home" title="Home"> | ||
| <p> | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur | ||
| condimentum lacus nec ligula faucibus rhoncus. Vestibulum ante | ||
| ipsum primis in faucibus orci luctus et ultrices posuere cubilia | ||
| Curae;{" "} | ||
| </p> | ||
| </RBTab> | ||
| <RBTab eventKey="profile" title="Profile"> | ||
| <p> | ||
| Donec dignissim ultricies felis, eu dictum eros congue in. In | ||
| gravida lobortis libero nec tempus. Cras rutrum nisl ut leo | ||
| volutpat rhoncus. Nulla massa nulla, viverra hendrerit laoreet at, | ||
| tincidunt eu lacus. | ||
| </p> | ||
| </RBTab> | ||
| <RBTab eventKey="contact" title="Contact" disabled> | ||
| <p> | ||
| Vivamus metus nulla, fermentum eget placerat vitae, mollis | ||
| interdum elit. Pellentesque arcu augue, vulputate ut porttitor ut, | ||
| suscipit non orci. Integer justo odio, suscipit eget tortor nec, | ||
| molestie lobortis eros. Nullam commodo elit sit amet lacus blandit | ||
| aliquet. Mauris at nibh eget nisl pulvinar dignissim. | ||
| </p> | ||
| </RBTab> | ||
| </RBTabs> | ||
| </Col> | ||
| <Col> | ||
| <Tabs activeKey='profile'> | ||
| <Tab eventKey="home" title="Home"><p>Home home</p></Tab> | ||
| <Tab eventKey="profile" title="Profile"><p>Profile profile</p></Tab> | ||
| <Tab eventKey="contact" title="Contact"disabled><p>Contact contact</p></Tab> | ||
| </Tabs> | ||
| </Col> | ||
| </Row> | ||
| ); | ||
| }; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| export default Task04; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,42 @@ | ||
| import React from 'react'; | ||
| import Card from "../src/components/Card/Card"; | ||
| import Button from '../src/components/Button/Button'; | ||
|
|
||
| import { Row, Col, Card as RBCard, Button as RBButton } from 'react-bootstrap'; | ||
| import { Row, Col, Card as RBCard, Button as RBButton } from "react-bootstrap"; | ||
|
|
||
| const Task05 = () => { | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBCard style={{ width: '18rem' }}> | ||
| <RBCard.Img variant="top" src="https://picsum.photos/100/80" /> | ||
| <RBCard.Body> | ||
| <RBCard.Title>Card Title</RBCard.Title> | ||
| <RBCard.Text> | ||
| Some quick example text to build on the card title and make up the bulk of | ||
| the card's content. | ||
| </RBCard.Text> | ||
| <RBButton variant="primary">Go somewhere</RBButton> | ||
| </RBCard.Body> | ||
| </RBCard> | ||
| </Col> | ||
| <Col> | ||
| Card! | ||
| </Col> | ||
| </Row> | ||
| ) | ||
| } | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBCard style={{ width: "18rem" }}> | ||
| <RBCard.Img variant="top" src="https://picsum.photos/100/80" /> | ||
| <RBCard.Body> | ||
| <RBCard.Title>Card Title</RBCard.Title> | ||
| <RBCard.Text> | ||
| Some quick example text to build on the card title and make up the | ||
| bulk of the card's content. | ||
| </RBCard.Text> | ||
| <RBButton variant="primary">Go somewhere</RBButton> | ||
| </RBCard.Body> | ||
| </RBCard> | ||
| </Col> | ||
| <Col> | ||
| <Card> | ||
| <Card.Img src="https://picsum.photos/100/80" /> | ||
| <Card.Body> | ||
| <Card.Title>Card Title</Card.Title> | ||
| <Card.Text> | ||
| {" "} | ||
| Some quick example text to build on the card title and make up the | ||
| bulk of the card's content. | ||
| </Card.Text> | ||
| <Button variant="primary" size='sm' active>Go somewhere</Button> | ||
| </Card.Body> | ||
| </Card> | ||
| </Col> | ||
| </Row> | ||
| ); | ||
| }; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| export default Task05; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,15 @@ import styled from 'styled-components'; | |
|
|
||
| const StyledAlert = styled.div` | ||
| display: block; | ||
| padding: 12px 20px; | ||
| margin: 0 0 10px; | ||
| --color-alfa: ${ props => props.theme.colorAlfa}; | ||
| color: var(--color-alfa); | ||
| border-radius: 5px; | ||
| background-color: ${ | ||
| props => props.variant === 'primary' | ||
| ? '#5585b5' : '#bbe4e9' | ||
| }; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| ` | ||
|
|
||
| export { StyledAlert }; | ||
| export { StyledAlert }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from "react"; | ||
| import BreadcrumbItem from "./BreadcrumbItem"; | ||
|
|
||
| const Breadcrumb = ({children}) => { | ||
| const style = {display: 'flex'} | ||
| return ( | ||
| <nav><ul style={style}>{children}</ul></nav> | ||
| ) | ||
| } | ||
|
|
||
| Breadcrumb.Item = BreadcrumbItem; | ||
|
|
||
| export default Breadcrumb; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gdzie odpowiednie tło dla okruchów chleba? :P |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import React from "react"; | ||
| import { StyledBreadItem } from "./BreadcrumbItem.styled"; | ||
|
|
||
| const BreadcrumbItem = ({children, href, active}) => { | ||
| return ( | ||
| <StyledBreadItem active={active}><a href={href}>{children}</a></StyledBreadItem> | ||
| ) | ||
| } | ||
|
|
||
| export default BreadcrumbItem; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import styled from "styled-components"; | ||
|
|
||
| const StyledBreadItem = styled.li` | ||
| list-style-type: none; | ||
| &:nth-child(1) { | ||
| &:before { | ||
| content: none; | ||
| } | ||
| } | ||
| &:before { | ||
| content: "/"; | ||
| padding: 10px; | ||
| color: grey; | ||
| } | ||
| ${({ active }) => | ||
| active && | ||
| `color: grey; | ||
| `} | ||
| `; | ||
|
|
||
| export { StyledBreadItem }; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React, { useState } from "react"; | ||
|
|
||
| import { StyledButton, theme } from "./Button.styled"; | ||
| import { ThemeProvider } from "styled-components"; | ||
|
|
||
| const Button = ({children, variant, size, disabled, active}) => { | ||
| const [isActive, setIsActive] = useState(false); | ||
|
|
||
| return ( | ||
| <ThemeProvider theme={theme}> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Motyw najlepiej zdefiniować jak najwyżej w strukturze komponentów (np. w App), aby nie trzeba było go definiować wielokrotnie dla każdego elementu. Rozumiem, że w tym zadaniu było tak wygodniej, ale już w projekcie nalezy to zrobić inaczej ;) |
||
| <StyledButton onClick={() => setIsActive(true)} variant={ variant } size={ size } disabled={ disabled } active={ active }>{children}</StyledButton> | ||
| </ThemeProvider> | ||
| ) | ||
| } | ||
|
|
||
| export default Button; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import styled, {css} from "styled-components"; | ||
|
|
||
|
|
||
|
|
||
| const theme = { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docelowo w projekcie mamy 1 motyw. Ewentualnie można definiować wartości domyślne tutaj. |
||
| button: { | ||
| primary: { | ||
| backgroundColor: '#0069D9', | ||
| color: '#fff', | ||
| hoverBackgroundColor: '#0022D9', | ||
| activeBackgroundColor: '#0022D9', | ||
| activeOutline: '3px solid #0099D9', | ||
| }, | ||
| secondary: { | ||
| backgroundColor: '#5585b5', | ||
| color: '#fff', | ||
| hoverBackgroundColor: '#5055c5', | ||
| activeBackgroundColor: '#5055c5', | ||
| activeOutline: '3px solid #5585b5' | ||
| }, | ||
| sizes: { | ||
| lg: { | ||
| padding: '8px 16px', | ||
| fontSize: '20px', | ||
| }, | ||
| sm: { | ||
| padding: '6px 10px', | ||
| fontSize: '16px', | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const StyledButton = styled.button` | ||
| border-radius: 5px; | ||
| border: 3px solid transparent; | ||
| margin: 10px 5px; | ||
| &:disabled { | ||
| opacity: 0.5; | ||
| pointer-events: none; | ||
| } | ||
| &:focus { | ||
| outline: none; | ||
| } | ||
| ${({ theme, variant }) => | ||
| variant === 'primary' && | ||
| css` | ||
| background-color: ${theme.button.primary.backgroundColor}; | ||
| color: ${theme.button.primary.color}; | ||
| &:hover { | ||
| background-color: ${theme.button.primary.hoverBackgroundColor}; | ||
| transition: 300ms; | ||
| } | ||
| `} | ||
| ${({ theme, variant, active }) => | ||
| variant === 'primary' && active && | ||
| css` | ||
| &:focus { | ||
| background-color: ${theme.button.primary.activeBackgroundColor}; | ||
| outline: ${theme.button.primary.activeOutline}; | ||
| transition: 100ms; | ||
| } | ||
| `} | ||
| ${({ theme, variant }) => | ||
| variant === 'secondary' && | ||
| css` | ||
| background-color: ${theme.button.secondary.backgroundColor}; | ||
| color: ${theme.button.secondary.color}; | ||
| &:hover { | ||
| background-color: ${theme.button.secondary.hoverBackgroundColor}; | ||
| } | ||
| `} | ||
| ${({ theme, variant, active }) => | ||
| variant === 'secondary' && active && | ||
| css` | ||
| &:focus { | ||
| background-color: ${theme.button.secondary.activeBackgroundColor}; | ||
| outline: ${theme.button.secondary.activeOutline}; | ||
| } | ||
| `} | ||
|
|
||
| ${({ theme, size }) => | ||
| size === 'lg' && | ||
| css` | ||
| padding: ${theme.button.sizes.lg.padding}; | ||
| font-size: ${theme.button.sizes.lg.fontSize}; | ||
| `} | ||
|
|
||
| ${({ theme, size }) => | ||
| size === 'sm' && | ||
| css` | ||
| padding: ${theme.button.sizes.sm.padding}; | ||
| font-size: ${theme.button.sizes.sm.fontSize}; | ||
| `} | ||
| } | ||
| `; | ||
|
|
||
| export { StyledButton, theme } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import Button from "./Button"; | ||
|
|
||
| export default Button; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍