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
22 changes: 13 additions & 9 deletions 02/Task02.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ 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 variant="primary" size="lg">
Button!
</Button>
</Col>
</Row>
);
Copy link
Owner

Choose a reason for hiding this comment

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

👍

}

export default Task02;
Expand Down
43 changes: 25 additions & 18 deletions 03/Task03.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
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/Breadcrumb/Breadcrumb";

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.Item href="#">Home</Breadcrumb.Item>
<Breadcrumb.Item href="https://getbootstrap.com/docs/4.0/components/breadcrumb/">
Library
</Breadcrumb.Item>
<Breadcrumb.Item active={true}>Data</Breadcrumb.Item>
</Breadcrumb>
</Col>
</Row>
);
};
Copy link
Owner

Choose a reason for hiding this comment

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

👍


export default Task03;

98 changes: 77 additions & 21 deletions 04/Task04.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,85 @@
import React from 'react';

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

const tabs = [
{
id: "home",
title: "Home",
content: (
<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>
),
},
{
id: "profile",
title: "Proflie",
content: (
<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>
),
},
{
id: "contact",
title: "Contact",
content: (
<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>
),
disabled: true,
},
];
Copy link
Owner

Choose a reason for hiding this comment

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

👍


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={tabs} defaultActiveId="home" />
Copy link
Owner

Choose a reason for hiding this comment

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

Dasz radę zbudować ten komponent podobnie jak wyżej? tj. przez children przekazać zawartość? Tak jest trochę trudniej, ale za to wygodniej jest wykorzystywać to rozwiązanie.

PS. Tutaj znajdziesz przydatne metody: https://react.dev/reference/react/Children

Copy link
Author

Choose a reason for hiding this comment

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

W pierwszej wersji korzystałem z tego rozwiązania jednak dokumentacja nie rekomenduje używania Children.
Zrobię je jednak i w tej wersji.

</Col>
</Row>
);
};

export default Task04;

53 changes: 32 additions & 21 deletions 05/Task05.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
import React from 'react';

import { Row, Col, Card as RBCard, Button as RBButton } from 'react-bootstrap';
import Card from "../src/components/Card";

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 style={{ width: "18rem" }}>
<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>
<Card.Button variant="primary">Go somewhere</Card.Button>
</Card.Body>
</Card>
</Col>
</Row>
);
};
Copy link
Owner

Choose a reason for hiding this comment

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

👍


export default Task05;

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;
29 changes: 27 additions & 2 deletions src/components/Alert/Alert.styled.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import styled from 'styled-components';
import defaultTheme from "../../themes/defaultTheme";

const StyledAlert = styled.div`
display: block;
`
display: block;
padding: 0.75rem 1.25rem;
border-width: 1px;
border-style: solid;
border-radius: 0.25em;

${({ theme, variant }) => {
const alertTheme = {
...defaultTheme?.alert?.variant,
...theme?.alert?.variant,
};
const { color, borderColor, backgroundColor } = alertTheme[variant];

return `
color: ${color};
background-color: ${backgroundColor};
border-color: ${borderColor};
`;
}}
`;

StyledAlert.defaultProps = {
variant: "primary",
theme: defaultTheme,
};

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 };
15 changes: 15 additions & 0 deletions src/components/Breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { StyledBreadcrumb } from "./Breadcrumb.styled";
import BreadcrumbItem from "./BreadcrumbItem";

function Breadcrumb({ children }) {
return (
<nav>
<StyledBreadcrumb>{children}</StyledBreadcrumb>
</nav>
);
}

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.

👍

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

const StyledBreadcrumb = styled.ol`
background-color: #e9ecef;
padding: 0.75em 1em;
border-radius: 0.2em;
display: flex;
list-style: none;
flex-wrap: wrap;
`;

export { StyledBreadcrumb };
16 changes: 16 additions & 0 deletions src/components/Breadcrumb/BreadcrumbItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { StyledBreadcrumbItem } from "./BreadcrumbItem.styled";

function BreadcrumbItem({ children, href, active }) {
if (active) {
return <StyledBreadcrumbItem>{children}</StyledBreadcrumbItem>;
}

return (
<StyledBreadcrumbItem>
<a href={href}>{children}</a>
</StyledBreadcrumbItem>
);
}

export default BreadcrumbItem;
Copy link
Owner

Choose a reason for hiding this comment

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

👍

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 from "styled-components";

const StyledBreadcrumbItem = styled.li`
color: gray;

&:not(:first-child)::before {
content: "/";
padding-inline: 0.5rem;
}
`;

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

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

import { StyledButton } from "./Button.styled";

const Button = ({ children, variant, size, disabled, active }) => {
return (
<StyledButton
variant={variant}
size={size}
disabled={disabled}
active={active}
>
{children}
</StyledButton>
);
};

export default Button;
Loading