Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions 01/Task01.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import React from 'react';

import { ThemeProvider } from 'styled-components';
import Alert from './../src/components/Alert';
import { Row, Col, Alert as RBAlert } from 'react-bootstrap';

const Task01 = () => {
const themeSettings = {
Copy link
Owner

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. :)

primary: {
color: '#004085',
backgroundColor: '#CCE5FF',
border: '1px solid #B8DAFF',
},
secondary: {
color: '#383D41',
backgroundColor: '#E2E3E5',
border: '1px solid #D6D8DB',
}

}
return (
<Row>
<Col>
<RBAlert variant="primary">Uwaga! <em>Styled Components</em> nadchodzi!</RBAlert>
</Col>
<Col>
<Alert>Uwaga! <em>Styled Components</em> nadchodzi!</Alert>
<ThemeProvider theme={themeSettings}>
<Alert variant='primary'>Uwaga! <em>Styled Components</em> nadchodzi!</Alert>
</ThemeProvider>
</Col>
</Row>
)
Expand Down
9 changes: 7 additions & 2 deletions 02/Task02.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

</Col>
</Row>
)
Expand Down
7 changes: 6 additions & 1 deletion 03/Task03.js
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';

Expand All @@ -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>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

</Col>
</Row>
)
Expand Down
6 changes: 4 additions & 2 deletions 04/Task04.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import Tabs from '../src/components/Tabs/Tabs';
import Tab from '../src/components/Tabs/Tab';

import { Row, Col, Tabs as RBTabs, Tab as RBTab, } from 'react-bootstrap';
import { Row, Col, Tabs as RBTabs, Tab as RBTab } from 'react-bootstrap';

const Task04 = () => {
return (
Expand All @@ -19,7 +21,7 @@ const Task04 = () => {
</RBTabs>
</Col>
<Col>
Tabs!
<Tabs />
</Col>
</Row>
)
Expand Down
20 changes: 19 additions & 1 deletion 05/Task05.js
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 = () => {
Expand All @@ -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>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

</Col>
</Row>
)
Expand Down
4 changes: 1 addition & 3 deletions src/components/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import React from 'react';
import { StyledAlert } from './Alert.styled';

const Alert = props => {
return (
<StyledAlert>{props.children}</StyledAlert>
);
return <StyledAlert variant={props.variant}>{props.children}</StyledAlert>
}

export default Alert;
8 changes: 7 additions & 1 deletion src/components/Alert/Alert.styled.js
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 };
12 changes: 7 additions & 5 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Container, Row, Col } from 'react-bootstrap';
import ResetStyle from './ResetStyle';

import Task01 from './../../01/Task01';
import Task02 from './../../02/Task02';
Expand All @@ -11,6 +12,7 @@ import Task05 from './../../05/Task05';
const App = () => {
return (
<>
<ResetStyle />
<Container fluid>
<Row>
<Col>
Expand All @@ -19,11 +21,11 @@ const App = () => {
<h2>Komponenty Twoje</h2>
</Col>
</Row>
<Task01/>
<Task02/>
<Task03/>
<Task04/>
<Task05/>
<Task01 />
<Task02 />
<Task03 />
<Task04 />
<Task05 />
</Container>
</>
)
Expand Down
13 changes: 13 additions & 0 deletions src/components/Breadcrumb/Breadcrumb.js
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,
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

11 changes: 11 additions & 0 deletions src/components/Breadcrumb/Breadcrumb.styled.js
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
21 changes: 21 additions & 0 deletions src/components/Breadcrumb/BreadcrumbItem.js
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tak jak wspominałem - można też mieć jeden plik .styled i do niego wrzucać komponenty stylowane - nawet jeśli jest to jakieś pierdółka ;)


const BreadcrumbItem = ({ href, active, children }) => {
return (
<StyledBreadcrumbElement active={active}>
{href ? <StyledBreadcrumbItem href={href} active={active}>{children}</StyledBreadcrumbItem> : children}
</StyledBreadcrumbElement>
)
}

export { BreadcrumbItem }
12 changes: 12 additions & 0 deletions src/components/Breadcrumb/BreadcrumbItem.styled.js
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 }
8 changes: 8 additions & 0 deletions src/components/Button/Button.js
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
25 changes: 25 additions & 0 deletions src/components/Button/Button.styled.js
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 }


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

3 changes: 3 additions & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Button from "./Button";

export default Button
23 changes: 23 additions & 0 deletions src/components/Button/theme.js
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
14 changes: 14 additions & 0 deletions src/components/Card/Card.js
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,
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

45 changes: 45 additions & 0 deletions src/components/Card/Card.styled.js
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 }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

8 changes: 8 additions & 0 deletions src/components/Card/CardBody.js
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
Loading