Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion 04/Task04.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Task04 = () => {
<Tab label="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 label="Profile">
<Tab label="Profile" active>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

<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 label="Contact" disabled>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ten miał być nieklikany :P

Expand Down
13 changes: 10 additions & 3 deletions src/components/Tabs/Tab.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import React from "react";
import { TabButton } from "./Tabs.styled";

const Tab = ({ label, active, children, onClick }) => {
const Tab = ({ label, active, disabled, children, onClick }) => {
const handleClick = () => {
if (!disabled) {
onClick(label);
}
};

return (
<TabButton
onClick={() => onClick(label)}
className={active ? "active" : ""}
onClick={handleClick}
className={`${active ? "active" : ""} ${disabled ? "disabled" : ""}`}
disabled={disabled}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

>
{label}
</TabButton>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { TabList, TabsContainer, TabContent } from './Tabs.styled';

const Tabs = ({ children }) => {
const [activeTab, setActiveTab] = useState(children[0].props.label);
const [activeTab, setActiveTab] = useState('Profile');
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍


const handleClick = (label) => {
setActiveTab(label);
Expand Down
9 changes: 9 additions & 0 deletions src/components/Tabs/Tabs.styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ const TabButton = styled.button`
background-color: #fff;
border-color: #dee2e6 #dee2e6 #fff;
}

&:not(.active) {
color: #007bff;
}

&:not(.active):hover {
border0color: transparent;
color: #0056b3;
}

&.disabled {
color: #6c757d;
cursor: default;
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

`;

const TabContent = styled.div`
Expand Down