-
-
Notifications
You must be signed in to change notification settings - Fork 76
practice-react-styling #55
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 |
|---|---|---|
|
|
@@ -5,15 +5,17 @@ import { Row, Col, Button as RBButton } from 'react-bootstrap'; | |
|
|
||
| const Task02 = () => { | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBButton variant="primary" size="lg">Button!</RBButton> | ||
| </Col> | ||
| <Col> | ||
| Button! | ||
| </Col> | ||
| </Row> | ||
| ) | ||
| <Row> | ||
| <Col> | ||
| <RBButton variant="primary" size="lg"> | ||
| Button! | ||
| </RBButton> | ||
| </Col> | ||
| <Col> | ||
| <Button>Button!</Button> | ||
| </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 Task02; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,25 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Row, Col, Breadcrumb as RBBreadcrumb } from 'react-bootstrap'; | ||
| import Breadcrumb from '../src/components/Breadcrumb' | ||
| import { Row, Col, Breadcrumb as RBBreadcrumb } from 'react-bootstrap' | ||
|
|
||
| const Task03 = () => { | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBBreadcrumb> | ||
| <RBBreadcrumb.Item href="#">Home</RBBreadcrumb.Item> | ||
| <RBBreadcrumb.Item href="https://getbootstrap.com/docs/4.0/components/breadcrumb/"> | ||
| Library | ||
| </RBBreadcrumb.Item> | ||
| <RBBreadcrumb.Item active>Data</RBBreadcrumb.Item> | ||
| </RBBreadcrumb> | ||
| </Col> | ||
| <Col> | ||
| Breadcrumb! | ||
| </Col> | ||
| </Row> | ||
| ) | ||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBBreadcrumb> | ||
| <RBBreadcrumb.Item href="#">Home</RBBreadcrumb.Item> | ||
|
|
||
| <RBBreadcrumb.Item href="https://getbootstrap.com/docs/4.0/components/breadcrumb/">Library</RBBreadcrumb.Item> | ||
|
|
||
| <RBBreadcrumb.Item active>Data</RBBreadcrumb.Item> | ||
| </RBBreadcrumb> | ||
| </Col> | ||
| <Col> | ||
| <Breadcrumb></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. Zobacz, że tutaj nie przekazujesz danych - masz na sztywno je zapisane. Jak będziesz chciał wyświetlać różne dane? Na każdej podstronie musi być inna ścieżka (Zawartość). |
||
| </Col> | ||
| </Row> | ||
| ) | ||
| } | ||
|
|
||
| export default Task03; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,39 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Row, Col, Tabs as RBTabs, Tab as RBTab, } from 'react-bootstrap'; | ||
| import Tabs from '../src/components/Tabs/Tabs' | ||
| 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></Tabs> | ||
|
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. Tak jak już pisałem - musi to być bardziej elastyczne. |
||
| </Col> | ||
| </Row> | ||
| ) | ||
| } | ||
|
|
||
| export default Task04; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,28 @@ | ||
| import React from 'react'; | ||
| import Card from '../src/components/Card/Card' | ||
|
|
||
| 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 /> | ||
|
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. Tutaj podobnie. Zwróć uwagę jak wygląda zapis wyżej. |
||
| </Col> | ||
| </Row> | ||
| ) | ||
| } | ||
|
|
||
| export default Task05; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,18 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { StyledAlert } from './Alert.styled'; | ||
| import { StyledAlert } from './Alert.styled' | ||
| import { ThemeProvider } from 'styled-components' | ||
|
|
||
| const themeSettings = { | ||
| colorAlfa: 'royalblue', | ||
| } | ||
|
|
||
| const Alert = props => { | ||
| return ( | ||
| <StyledAlert>{props.children}</StyledAlert> | ||
| ); | ||
| return ( | ||
| <ThemeProvider theme={themeSettings}> | ||
|
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 warto mieć jeden motyw dla całej strony/aplikacji - w zadaniach może zostać ;) |
||
| <StyledAlert variant="primary">{props.children}</StyledAlert> | ||
| </ThemeProvider> | ||
| ) | ||
| } | ||
|
|
||
| export default Alert; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,24 @@ | ||
| import styled from 'styled-components'; | ||
| import styled, { css } from 'styled-components' | ||
|
|
||
| const variantStyles = { | ||
| primary: css` | ||
| background-color: red; | ||
| color: #fce2c2; | ||
| `, | ||
| secondary: css` | ||
| background-color: green; | ||
| color: #fce2c2; | ||
| `, | ||
| } | ||
|
|
||
| const StyledAlert = styled.div` | ||
| display: block; | ||
| --color-alfa: ${props => props.theme.colorAlfa}; | ||
| display: block; | ||
| border: 1px solid darken(var(--color-alfa), 10%); | ||
| background-color: var(--color-alfa); | ||
| ${props => props.variant && variantStyles[props.variant]}; | ||
| border-radius: 5px; | ||
| padding: 12px 15px; | ||
|
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,19 @@ | ||
| const BreadcrumItems = [ | ||
| { | ||
| name: 'Home', | ||
| active: false, | ||
| id: 1, | ||
| }, | ||
| { | ||
| name: 'Library', | ||
| active: false, | ||
| id: 2, | ||
| }, | ||
| { | ||
| name: 'Data', | ||
| active: true, | ||
| id: 3, | ||
| }, | ||
| ] | ||
|
|
||
| export { BreadcrumItems } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import React from 'react' | ||
|
|
||
| import BreadcrumbItem from './BreadcrumbItem' | ||
| import { StyledBreadcrumb } from './Breadcrumb.styled' | ||
|
|
||
| const Breadcrumb = props => { | ||
| // return <StyledBreadcrumb>{props.children}</StyledBreadcrumb> | ||
| return ( | ||
| <StyledBreadcrumb> | ||
| <BreadcrumbItem></BreadcrumbItem> | ||
| </StyledBreadcrumb> | ||
| ) | ||
| } | ||
|
|
||
| export default Breadcrumb |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import styled, { css } from 'styled-components' | ||
|
|
||
| const StyledBreadcrumb = styled.ol` | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| padding: 0.75rem 1rem; | ||
| margin-bottom: 1rem; | ||
| list-style: none; | ||
| background-color: #e9ecef; | ||
| border-radius: 0.25rem; | ||
| ` | ||
|
|
||
| export { StyledBreadcrumb } | ||
|
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,19 @@ | ||
| import React from 'react' | ||
|
|
||
| import { StyledBreadcrumbItem } from './BreadcrumbItem.styled' | ||
| import { BreadcrumItems } from './BreadCrumbItems' | ||
|
|
||
| const BreadcrumbItem = () => { | ||
| const item = BreadcrumItems.map(item => ( | ||
| <StyledBreadcrumbItem key={item.id}> | ||
| <a href="#" className={item.active ? 'active' : ''}> | ||
| {item.name} | ||
| </a> | ||
| <span>/</span> | ||
| </StyledBreadcrumbItem> | ||
| )) | ||
|
|
||
| return item | ||
| } | ||
|
|
||
| export default BreadcrumbItem |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import styled, { css } from 'styled-components' | ||
|
|
||
| const StyledBreadcrumbItem = styled.li` | ||
| a { | ||
| color: #007bff; | ||
| text-decoration: none; | ||
| background-color: transparent; | ||
|
|
||
| &:hover { | ||
| text-decoration: underline; | ||
| } | ||
|
|
||
| &.active { | ||
| cursor: default; | ||
| color: #6c757d; | ||
| text-decoration: none; | ||
| } | ||
| } | ||
| span { | ||
| margin: 0 0.5rem; | ||
| content: '⛅ '; | ||
| } | ||
| ` | ||
|
|
||
| export { StyledBreadcrumbItem } | ||
|
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,3 @@ | ||
| import Breadcrumb from './Breadcrumb' | ||
|
|
||
| export default Breadcrumb |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import React from 'react' | ||
|
|
||
| import { StyledButton } from './Button.styled' | ||
| import { ThemeProvider } from 'styled-components' | ||
|
|
||
| const themeSettings = { | ||
| colorAlfa: 'royalblue', | ||
| padding: '1rem 2rem', | ||
| fontSize: '1.5rem', | ||
| } | ||
|
|
||
| const Button = props => { | ||
| return ( | ||
| <ThemeProvider theme={themeSettings}> | ||
|
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 (theme) powinien być poza samym komponent aby można było go definiować dowolnie w każdy aplikacji. W tym przypadku moglibyśmy po prostu go ostylować bez motywu. |
||
| <StyledButton variant="primary" size="xl" disabled={false}> | ||
| {props.children} | ||
| </StyledButton> | ||
| </ThemeProvider> | ||
| ) | ||
| } | ||
|
|
||
| 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.
👍