-
-
Notifications
You must be signed in to change notification settings - Fork 76
Not finished #46
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?
Not finished #46
Changes from all commits
d920e0e
cda0758
fe28616
495aa96
79b345c
d8d17ae
a4633e8
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 |
|---|---|---|
|
|
@@ -2,15 +2,20 @@ import React from 'react'; | |
|
|
||
| import Button from './../src/components/Button'; | ||
| import { Row, Col, Button as RBButton } from 'react-bootstrap'; | ||
| import { ThemeProvider } from 'styled-components'; | ||
| import themeSettings from './../src/components/Button/theme' | ||
|
|
||
| const Task02 = () => { | ||
|
|
||
| return ( | ||
| <Row> | ||
| <Col> | ||
| <RBButton variant="primary" size="lg">Button!</RBButton> | ||
| <RBButton variant="primary" size="lg" >Button!</RBButton> | ||
| </Col> | ||
| <Col> | ||
| Button! | ||
| <ThemeProvider theme={themeSettings}> | ||
| <Button variant='primary' size='lg' >Button!</Button> | ||
| </ThemeProvider> | ||
|
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,4 +1,5 @@ | ||
| import React from 'react'; | ||
| import Breadcrumb from '../src/components/Breadcrumb/Breadcrumb'; | ||
|
|
||
| import { Row, Col, Breadcrumb as RBBreadcrumb } from 'react-bootstrap'; | ||
|
|
||
|
|
@@ -15,7 +16,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,5 +1,11 @@ | ||
| import React from 'react'; | ||
|
|
||
| import Card from '../src/components/Card/Card'; | ||
| import Button from './../src/components/Button'; | ||
|
|
||
| import { ThemeProvider } from 'styled-components'; | ||
| import themeSettings from '../src/components/Button/theme'; | ||
|
|
||
| import { Row, Col, Card as RBCard, Button as RBButton } from 'react-bootstrap'; | ||
|
|
||
| const Task05 = () => { | ||
|
|
@@ -19,7 +25,19 @@ const Task05 = () => { | |
| </RBCard> | ||
| </Col> | ||
| <Col> | ||
| Card! | ||
| <Card style={{ width: '18rem' }}> | ||
| <Card.Img variant="top" 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> | ||
| <ThemeProvider theme={themeSettings}> | ||
| <Button variant="primary">Go somewhere</Button> | ||
| </ThemeProvider> | ||
| </Card.Body> | ||
| </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. 👍 |
||
| </Col> | ||
| </Row> | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| import styled from 'styled-components'; | ||
|
|
||
| const StyledAlert = styled.div` | ||
| const DefaultStyledAlert = styled.div` | ||
| display: block; | ||
| margin-bottom: 16px; | ||
| padding: 12px 20px; | ||
| border-radius: 4px; | ||
| ` | ||
| const StyledAlert = styled(DefaultStyledAlert)( | ||
| ({ variant, theme }) => theme[variant] | ||
| ) | ||
|
|
||
| export { StyledAlert }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from "react"; | ||
| import StyledBreadcrumb from "./Breadcrumb.styled"; | ||
| import { BreadcrumbItem } from './BreadcrumbItem' | ||
|
|
||
| const Breadcrumb = (props) => { | ||
| return <StyledBreadcrumb> | ||
| {props.children} | ||
| </StyledBreadcrumb> | ||
| } | ||
|
|
||
| export default Object.assign(Breadcrumb, { | ||
| Item: 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,11 @@ | ||
| import styled from "styled-components"; | ||
|
|
||
| const StyledBreadcrumb = styled.ol` | ||
| display: flex; | ||
| padding: 12px 16px; | ||
| list-style: none; | ||
| background-color: #E9ECEF; | ||
| border-radius: 0.25rem | ||
| ` | ||
|
|
||
| export default StyledBreadcrumb |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from "react"; | ||
| import { StyledBreadcrumbItem } from "./BreadcrumbItem.styled"; | ||
| import styled from "styled-components"; | ||
|
|
||
| const StyledBreadcrumbElement = styled.li` | ||
| & + &::before { | ||
| content: '/'; | ||
| padding: 8px | ||
| } | ||
| ${props=> props.active && {color:'#6c757d'}} | ||
| ` | ||
|
Comment on lines
+2
to
+11
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 wspominałem - można też mieć jeden plik |
||
|
|
||
| const BreadcrumbItem = ({ href, active, children }) => { | ||
| return ( | ||
| <StyledBreadcrumbElement active={active}> | ||
| {href ? <StyledBreadcrumbItem href={href} active={active}>{children}</StyledBreadcrumbItem> : children} | ||
| </StyledBreadcrumbElement> | ||
| ) | ||
| } | ||
|
|
||
| export { BreadcrumbItem } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import styled, { css } from "styled-components"; | ||
|
|
||
| const StyledBreadcrumbItem = styled.a.attrs(({ href }) => ({ | ||
| href: `${href}` | ||
| }))` | ||
| color: #007bff; | ||
| &:hover { | ||
| color: #0056b3; | ||
| } | ||
| ` | ||
|
|
||
| export { StyledBreadcrumbItem } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import React from "react"; | ||
| import { StyledButton } from './Button.styled' | ||
|
|
||
| const Button = ({variant, size, children, disabled}) => { | ||
| return <StyledButton disabled={disabled} variant={variant} size={size}>{children}</StyledButton> | ||
| } | ||
|
|
||
| export default Button |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import styled from "styled-components"; | ||
|
|
||
| const DefaultStyledButton = styled.button` | ||
| background-color: #ffffff; | ||
| padding: 6px 12px; | ||
| border-radius: 4px; | ||
| border: none; | ||
| &:focus { | ||
| outline: none | ||
| }; | ||
| &:active { | ||
| ${props => props.theme.active} | ||
| }; | ||
| &:disabled { | ||
| ${({ disabled, theme }) => disabled === true && theme.disabled} | ||
| } | ||
| ` | ||
|
|
||
| const StyledButton = styled(DefaultStyledButton)` | ||
| ${({ variant, theme }) => theme[variant]}; | ||
| ${({ size, theme }) => size === 'lg' && theme.large};` | ||
|
|
||
| export { StyledButton } | ||
|
|
||
|
|
||
|
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 Button from "./Button"; | ||
|
|
||
| export default Button |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| const themeSettings = { | ||
| primary: { | ||
| color: '#fff', | ||
| backgroundColor: '#007bff', | ||
| }, | ||
| secondary: { | ||
| color: '#FFFFFF', | ||
| backgroundColor: '#6C757D', | ||
| }, | ||
| large: { | ||
| padding: '8px 16px', | ||
| fontSize: '20px' | ||
| }, | ||
| disabled: { | ||
| backgroundColor: '#59A9FF' | ||
| }, | ||
| active: { | ||
| backgroundColor: '#0069D9', | ||
| boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)' | ||
| } | ||
| } | ||
|
|
||
| export default themeSettings |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import React from "react" | ||
| import { StyledCard } from "./Card.styled" | ||
| import { CardImg, CardBody, CardTitle, CardText } from "../Card" | ||
|
|
||
| const Card = (props) => { | ||
| return <StyledCard style={props.style}>{props.children}</StyledCard> | ||
| } | ||
|
|
||
| export default Object.assign(Card, { | ||
| Img: CardImg, | ||
| Body: CardBody, | ||
| Title: CardTitle, | ||
| Text: CardText, | ||
| }) | ||
|
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,45 @@ | ||
| import styled from "styled-components"; | ||
|
|
||
| const StyledCard = styled.div` | ||
| width: ${props => props.style.width}; | ||
| position: relative; | ||
| display: -ms-flexbox; | ||
| display: flex; | ||
| -ms-flex-direction: column; | ||
| flex-direction: column; | ||
| min-width: 0; | ||
| word-wrap: break-word; | ||
| background-color: #fff; | ||
| background-clip: border-box; | ||
| border: 1px solid rgba(0,0,0,.125); | ||
| border-radius: 0.25rem; | ||
| ` | ||
|
|
||
| const StyledCardImg = styled.img` | ||
| flex-shrink: 0; | ||
| width: 100%; | ||
| vertical-align: middle; | ||
| border-style: none; | ||
| border-top-left-radius: calc(0.25rem - 1px); | ||
| border-top-right-radius: calc(0.25rem - 1px); | ||
| ` | ||
|
|
||
| const StyledCardBody = styled.div` | ||
| flex: 1 1 auto; | ||
| min-height: 1px; | ||
| padding: 1.25rem; | ||
| ` | ||
|
|
||
| const StyledCardTitle = styled.div` | ||
| margin-bottom: 0.75rem; | ||
| font-size: 1.25rem; | ||
| font-weight: 500; | ||
| line-height: 1.2; | ||
| ` | ||
|
|
||
| const StyledCardText = styled.p` | ||
| margin-top: 0; | ||
| margin-bottom: 1rem; | ||
| ` | ||
|
|
||
| export { StyledCard, StyledCardImg, StyledCardBody, StyledCardTitle, StyledCardText } | ||
|
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,8 @@ | ||
| import React from "react"; | ||
| import { StyledCardBody } from "./Card.styled"; | ||
|
|
||
| const CardBody = (props) => { | ||
| return <StyledCardBody>{props.children}</StyledCardBody> | ||
| } | ||
|
|
||
| export default CardBody |
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.
Docelowo "theme" definiujemy w osobnym pliku i jest on przekazywany gdzieś na "górze" np. w
App.js.Na potrzeby zadań jest ok, ale w projekcie lepiej to zrobić tak jak piszę wyżej i zazwyczaj jest to jeden plik :)
PS. Wiem, że wygodniej jest trzymać całe deklaracje w motywie, ale lepiej tam trzymać tylko wartości tj. kolor, grubość obramowania itp. :)