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
6 changes: 5 additions & 1 deletion 01/Task01.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';

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

Choose a reason for hiding this comment

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

Jeszcze lepszym rozwiązaniem jest mieć 1 motyw dla całej aplikacji i przekazywać ją w głównym komponencie np. App.js - teraz bym nie zmieniał, ale w projekcie bym to uwzględnił :)


const Task01 = () => {
return (
Expand All @@ -10,7 +12,9 @@ const Task01 = () => {
<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
7 changes: 5 additions & 2 deletions 02/Task02.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';

import Button from './../src/components/Button';
import { Row, Col, Button as RBButton } from 'react-bootstrap';
import themeSettings from '../src/components/Button/theme'
import { ThemeProvider } from 'styled-components';

const Task02 = () => {
return (
Expand All @@ -10,7 +11,9 @@ const Task02 = () => {
<RBButton variant="primary" size="lg">Button!</RBButton>
</Col>
<Col>
Button!
<ThemeProvider theme={themeSettings}>
<Button variant="primary" > 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
12 changes: 10 additions & 2 deletions 03/Task03.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';

import { Row, Col, Breadcrumb as RBBreadcrumb } from 'react-bootstrap';
import { Row, Col, Breadcrumb as RBBreadcrumb} from 'react-bootstrap';
import Breadcrumb from '../src/components/Breadcrumbs/Breadcrumb';


const Task03 = () => {
return (
Expand All @@ -15,7 +17,13 @@ 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
13 changes: 12 additions & 1 deletion 04/Task04.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import { Row, Col, Tabs as RBTabs, Tab as RBTab, } from 'react-bootstrap';
import { Tab, Tabs } from "../src/components/Tabs/index"

const Task04 = () => {
return (
Expand All @@ -19,7 +20,17 @@ const Task04 = () => {
</RBTabs>
</Col>
<Col>
Tabs!
<Tabs initTab="profile">
<Tab eventKey="home" name="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>
</Tab>
<Tab eventKey="profile" name="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>
</Tab>
<Tab eventKey="contact" name="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>
</Tab>
</Tabs>
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
18 changes: 17 additions & 1 deletion 05/Task05.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';

import { Row, Col, Card as RBCard, Button as RBButton } from 'react-bootstrap';
import Card from '../src/components/Card/index';
import themeSettings from '../src/components/Button/theme'
import { ThemeProvider } from 'styled-components';
import Button from './../src/components/Button';

const Task05 = () => {
return (
Expand All @@ -19,7 +23,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"> Button!</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
2 changes: 1 addition & 1 deletion src/components/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StyledAlert } from './Alert.styled';

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

Expand Down
23 changes: 21 additions & 2 deletions src/components/Alert/Alert.styled.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import styled from 'styled-components';
import { propTypes } from 'react-bootstrap/esm/Image';
import styled, { css } from 'styled-components';


const StyledAlert = styled.div`
display: block;
border: 1px solid #000;
border-radius: 5px;
background-color: #fff;
color: #000;
padding: 0.8rem 1.2rem;
width: calc(100% - 20px);
margin: 12px 10px;
font-size: 16px;
${ ({variant, theme}) => {
const {backgroundColor, color, borderColor} = theme[variant] || {};

return css`
background-color: ${backgroundColor};
color: ${color};
border-color: ${borderColor};
`;
}
};
Copy link
Owner

Choose a reason for hiding this comment

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

👍

`

export { StyledAlert };
12 changes: 12 additions & 0 deletions src/components/Alert/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
primary: {
backgroundColor: '#031633',
color: '#6EA8FE',
borderColor: '#084298'
},
secondary: {
backgroundColor: '#161719',
color: '#A7ACB1',
borderColor: '#41464B'
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

W motywie zazwyczaj trzymamy wartości tj. wartość koloru, wielkość odstępu itp. jeśli będziesz trzymał całe style to okaże się, że cały CSS jest w motywie, a nie o to chodzi ;)

PS. To taka uwaga na przyszłość - nie chodzi o zmienianie tego teraz :)

9 changes: 9 additions & 0 deletions src/components/Breadcrumbs/Breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";
import BreadcrumbStyled from "./BreadcrumbStyled";
import BreadcrumbItem from "./BreadcrumbItem";

const Breadcrumb = ({ children }) => {
return <BreadcrumbStyled>{children}</BreadcrumbStyled>;
};

export default Object.assign(Breadcrumb, { Item: BreadcrumbItem });
16 changes: 16 additions & 0 deletions src/components/Breadcrumbs/BreadcrumbItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import BreadcrumbItemStyled from "./BreadCrumbItemStyled";
Copy link
Owner

Choose a reason for hiding this comment

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

Tutaj niepotrzebnie C z wielkiej litery - na windows to nie problem, ale na linuxie (serwerze) już rzuca błędem :)

import BreadcrumbItemContainer from "./BreadcrumbItemContainer";

const BreadcrumbItem = ({ href, children, active = true }) => {
return (
<BreadcrumbItemContainer>
<BreadcrumbItemStyled isActive={active} href={href}>
{children}
</BreadcrumbItemStyled>
</BreadcrumbItemContainer>

);
};

export default BreadcrumbItem;
21 changes: 21 additions & 0 deletions src/components/Breadcrumbs/BreadcrumbItemContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import styled from "styled-components";

const BreadcrumbItemContainer = styled.div`
display: inline-block;
margin-right: 0.5rem;
position: relative;

&:not(:last-child)::after {
content: "";
position: absolute;
top: 50%;
right: -0.5rem;
transform: translateY(-45%) rotate(20deg);
width: 1px;
height: 0.9em;
background-color: black;
}
`;


export default BreadcrumbItemContainer;
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/Breadcrumbs/BreadcrumbItemStyled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import styled, {css} from "styled-components";

const BreadcrumbItemStyled = styled.a.attrs(({href}) => ({
href: href,
}))`
padding: 0.5rem;
margin-left: 0.3rem;
display: inline-flex;
`

export default BreadcrumbItemStyled;
15 changes: 15 additions & 0 deletions src/components/Breadcrumbs/BreadcrumbStyled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from "styled-components";

const BreadcrumbStyled = styled.div`
border-radius: 5px;
background-color: #e9ecef;
padding: 0.4rem 1.2rem;
width: calc(100% - 20px);
margin: 12px 10px;
font-size: 16px;
display: flex;
flex-wrap: wrap;
list-style: none;
`;

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

export default Breadcrumb;
10 changes: 10 additions & 0 deletions src/components/Button/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import StyledButton from './Button.styled'

const Button = props => {
return (
<StyledButton variant={props.variant} size={props.size} isDisabled={props.disabled} isActive={props.active}>{props.children}</StyledButton>
)
}

export default Button
40 changes: 40 additions & 0 deletions src/components/Button/Button.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import styled, {css} from "styled-components";

const StyledButton = styled.button`
font-size: 20px;
border-radius: 5px;
border: none;
background-color: #fff;
color: #fff;
padding: 0.5rem 1rem;
transition: 0.5s;
${ ({variant, theme,isDisabled,isActive}) => {
const {backgroundColor,hoverBackgroundColor} = theme.variants[variant] || {};


if (isDisabled) {
return css`
Copy link
Owner

Choose a reason for hiding this comment

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

Można też return isDisabled && css...

background-color: gray;
cursor: not-allowed;
pointer-events:none;
`;
}

if (isActive) {
return css`
background-color: ${hoverBackgroundColor};
pointer-events:none;
`
}

return css `
background-color: ${backgroundColor};
&:hover {
background-color: ${hoverBackgroundColor}
}
`;
}
};
`

export default StyledButton
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;
17 changes: 17 additions & 0 deletions src/components/Button/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
variants: {
primary: {
backgroundColor: '#0098d9',
hoverBackgroundColor: '#0069D9'
},
secondary: {
backgroundColor: '#848b91',
hoverBackgroundColor: '#5C636A'
}
},
sizes: {
small: {fontSize: '10px'},
large: {fontSize: '20px'}
},

}
13 changes: 13 additions & 0 deletions src/components/Card/Body.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import StyledBody from "./StyledElements/StyledBody";

const Body = ({children}) => {
return (
<StyledBody>

{children}
</StyledBody>
)
}

export default Body;
21 changes: 21 additions & 0 deletions src/components/Card/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";

import Body from "./Body"
import Title from "./Title"
import Text from "./Text"
import Img from "./Img"

import StyledCard from "./StyledElements/StyledCard";

const Card = ({style, children}) => {
return (
<StyledCard style={style}>{children}</StyledCard>
)
}

export default Object.assign(Card, {
Img: Img,
Body: Body,
Title: Title,
Text: Text,
});
Copy link
Owner

Choose a reason for hiding this comment

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

👍

10 changes: 10 additions & 0 deletions src/components/Card/Img.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import StyledImg from "./StyledElements/StyledImg";

const Img = ({variant, src}) => {
return (
<StyledImg variant={variant} src={src}></StyledImg>
)
}

export default Img;
9 changes: 9 additions & 0 deletions src/components/Card/StyledElements/StyledBody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from "styled-components";

const StyledBody = styled.section`
display: flex;
flex-direction: column;
padding: 1.5rem 1rem;
`

export default StyledBody
Loading