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
12 changes: 7 additions & 5 deletions 01/Task01.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React from 'react';

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

const Task01 = () => {
return (
<Row>
<Col>
<RBAlert variant="primary">Uwaga! <em>Styled Components</em> nadchodzi!</RBAlert>
<RBAlert variant="info">
Uwaga! <em>Styled Components</em> nadchodzi!
</RBAlert>
</Col>
<Col>
<Alert>Uwaga! <em>Styled Components</em> nadchodzi!</Alert>
<Alert variant="info">
Uwaga! <em>Styled Components</em> nadchodzi!
</Alert>
</Col>
</Row>
)
);
}

export default Task01;

8 changes: 8 additions & 0 deletions 01/components/Alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import { StyledAlert } from './Alert.styled';

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

export default Alert;
17 changes: 17 additions & 0 deletions 01/components/Alert.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from 'styled-components';

const DefaultStyledAlert = styled.div`
display: block;
position: relative;
padding: 0.75rem 1.25rem;
margin-bottom: 1rem;
border: 1px solid transparent;
border-radius: 0.25rem;
`;

const StyledAlert = styled(DefaultStyledAlert)`
color: ${({ theme, variant }) => theme.color[variant]?.color};
background-color: ${({ theme, variant }) =>
theme.color[variant]?.backgroundColor};
border-color: ${({ theme, variant }) => theme.color[variant]?.borderColor};
`;
12 changes: 8 additions & 4 deletions 02/Task02.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import React from 'react';

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

const Task02 = () => {

return (
<Row>
<Col>
<RBButton variant="primary" size="lg">Button!</RBButton>
<RBButton variant="success" size="md">
Button!
</RBButton>
</Col>
<Col>
Button!
<Button variant="success" size="md">
Button!
</Button>
</Col>
</Row>
)
);
}

export default Task02;
Expand Down
17 changes: 17 additions & 0 deletions 02/components/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import StyledButton from './Button.styled';

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

export default Button;
34 changes: 34 additions & 0 deletions 02/components/Button.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import styled from 'styled-components';

const DefaultStyledButton = styled.button`
padding: 0.5rem 1rem;
font-size: 1.25rem;
line-height: 1.5;
border-radius: 0.3rem;
`;

const StyledButton = styled(DefaultStyledButton)`
color: ${({ theme, variant }) => theme.button[variant]?.color};
background-color: ${({ theme, variant }) =>
theme.button[variant]?.backgroundColor};
border-color: ${({ theme, variant }) => theme.button[variant]?.borderColor};
font-size: ${({ theme, size }) => theme.button.sizes[size]?.fontSize};
padding: ${({ theme, size }) => theme.button.sizes[size]?.padding};
opacity: ${({ active, disabled }) => (active ? 1.1 : disabled ? 0.6 : 1)};
&:hover {
color: ${({ theme, variant }) => theme.button[variant]?.hover.color};
background-color: ${({ theme, variant }) =>
theme.button[variant]?.hover.backgroundColor};
border-color: ${({ theme, variant }) =>
theme.button[variant]?.hover.borderColor};
}
&:active {
color: ${({ theme, variant }) => theme.button[variant]?.active.color};
background-color: ${({ theme, variant }) =>
theme.button[variant]?.active.backgroundColor};
border-color: ${({ theme, variant }) =>
theme.button[variant]?.active.borderColor};
}
`;

export default StyledButton;
3 changes: 3 additions & 0 deletions 02/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Button from './Button';

export default Button;
13 changes: 10 additions & 3 deletions 03/Task03.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ 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>
</Col>
</Row>
)
}
);
};


export default Task03;

11 changes: 11 additions & 0 deletions 03/components/Breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import StyledBreadcrumb from './Breadcrumb.styled';
import BreadcrumbItem from './BreadcrumbItem';

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

export default Object.assign(Breadcrumb, {
Item: BreadcrumbItem,
});
12 changes: 12 additions & 0 deletions 03/components/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.ul`
display: flex;
flex-wrap: wrap;
padding: 0.75rem 1rem;
list-style: none;
background-color: #e9ecef;
border-radius: 0.25rem;
`;

export default StyledBreadcrumb;
14 changes: 14 additions & 0 deletions 03/components/BreadcrumbItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { StyledBreadcrumbItem, StyledLink } from './BreadcrumbItem.styled';

const BreadcrumbItem = ({ href, children, active }) => {
return (
<StyledBreadcrumbItem>
<StyledLink href={href} className={active ? 'active' : ''}>
{children}
</StyledLink>
</StyledBreadcrumbItem>
);
};

export default BreadcrumbItem;
25 changes: 25 additions & 0 deletions 03/components/BreadcrumbItem.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styled from 'styled-components';

const StyledBreadcrumbItem = styled.li`
& + &::before {
content: '/';
padding: 8px;
}
`;

const StyledLink = styled.a`
color: #007bff;
text-decoration: none;
&:hover {
color: #0056b3;
text-decoration: underline;
}
&.active {
color: #6c757d;
pointer-events: none;
cursor: default;
text-decoration: none;
}
`;

export { StyledBreadcrumbItem, StyledLink };
30 changes: 23 additions & 7 deletions 04/Task04.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
import React from 'react';

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

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>
<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>
<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>
<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 />
</Col>
</Row>
)
}
);
};

export default Task04;

8 changes: 8 additions & 0 deletions 04/components/Tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import StyledTab from './Tab.styled';

const Tab = ({ active, content }) => {
return <StyledTab active={active}>{content}</StyledTab>;
};

export default Tab;
7 changes: 7 additions & 0 deletions 04/components/Tab.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styled from 'styled-components';

const StyledTab = styled.div`
display: ${(props) => (props.active ? 'block' : 'none')};
`;

export default StyledTab;
36 changes: 36 additions & 0 deletions 04/components/Tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useState } from 'react';
import tabsData from './tabsData';
import Tab from './Tab';
import StyledTabs from './Tabs.styled';

const Tabs = () => {
const [activeTab, setActiveTab] = useState(tabsData[0].name);

return (
<StyledTabs>
<div className="tab-buttons">
{tabsData.map((tab) => (
<button
key={tab.id}
disabled={tab.disabled}
onClick={() => setActiveTab(tab.name)}
className={tab.name === activeTab ? 'active' : ''}
>
{tab.title}
</button>
))}
</div>
<div className="tab-content">
{tabsData.map((tab) => (
<Tab
key={tab.id}
active={tab.name === activeTab}
content={tab.text}
/>
))}
</div>
</StyledTabs>
);
};

export default Tabs;
41 changes: 41 additions & 0 deletions 04/components/Tabs.styled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import styled from 'styled-components';

const StyledTabs = styled.div`
.tab-buttons {
display: flex;
border-bottom: 1px solid #dee2e6;
button {
margin-bottom: -1px;
padding: 0.5rem 1rem;
cursor: pointer;
border: 1px solid transparent;
border-bottom: none;
background-color: transparent;
transition: background-color 0.3s, border-color 0.3s;
color: #007bff;
font-size: 1rem;
line-height: 1.5;
border-radius: 0.25rem 0.25rem 0 0;
&:hover {
text-decoration: none;
}
&.active {
border-color: #dee2e6 #dee2e6 #fff;
background-color: #fff;
color: #495057;
}
&:focus {
outline: none;
box-shadow: none;
}
&[disabled] {
color: #6c757d;
pointer-events: none;
background-color: transparent;
border-color: transparent;
}
}
}
`;

export default StyledTabs;
Loading