Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
141 changes: 89 additions & 52 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { GlobalStyle } from "./styles/global-style";
import { lightTheme, darkTheme } from "./styles/themes";
import Button from "./lib/button";
import Tabs from "./lib/pagination/tabs";
import Card from "./lib/container/card";
import Buttons from "./examples/buttons";
import Pagination from "./examples/pagination";
import Containers from "./examples/containers";
Expand All @@ -19,6 +18,7 @@ import TimelineProgress from "./examples/timeline";
import Input from "./examples/input";
import Tooltips from "./examples/tooltip";
import Copiable from "./examples/copiable";
import clsx from "clsx";

const StyledDiv = styled.div`
position: fixed;
Expand All @@ -38,29 +38,9 @@ const StyledDiv = styled.div`
${(props) => props.theme.klerosUIComponentsTransitionSpeed};
`;

const StyledCard = styled(Card)`
height: 500px;
width: 1000px;
display: flex;
justify-content: space-around;
align-items: center;
gap: 24px;
overflow: auto;
flex-wrap: wrap;
padding: 36px 36px;
background: ${(props) => props.theme.klerosUIComponentsLightBackground};
transition: background ease
${(props) => props.theme.klerosUIComponentsTransitionSpeed};
`;

const StyledTabs = styled(Tabs)`
width: 995px;
`;

const App = () => {
const [theme, setTheme] = useState(lightTheme);
const [tailwindTheme, setTailwindTheme] = useState("light");
const [example, setExample] = useState("buttons");

// temporary
const changeTheme = () => {
Expand All @@ -80,40 +60,97 @@ const App = () => {
<ThemeProvider theme={theme}>
<GlobalStyle />
<StyledDiv>
<StyledTabs
<Tabs
className="w-[995px]"
defaultSelectedKey={"buttons"}
panelClassName={clsx(
"h-[500px] w-[1000px] bg-klerosUIComponentsLightBackground",
"transition-[background] ease-ease",
"border border-klerosUIComponentsStroke box-border",
"flex justify-around items-center gap-6 flex-wrap p-9",
"overflow-auto rounded-base shadow-sm shadow-klerosUIComponentsDefaultShadow-400",
)}
items={[
{ text: "Buttons", value: "buttons" },
{ text: "Pagination", value: "pagination" },
{ text: "Containers", value: "containers" },
{ text: "Accordion", value: "accordion" },
{ text: "Form", value: "form" },
{ text: "Dropdowns", value: "dropdowns" },
{ text: "Displays", value: "displays" },
{ text: "Messages", value: "messages" },
{ text: "Timeline", value: "timeline" },
{ text: "Progress", value: "progress" },
{ text: "Input", value: "input" },
{ text: "Tooltip", value: "tooltip" },
{ text: "Copiable", value: "copiable" },
{
text: "Buttons",
value: "buttons",
id: "buttons",
content: <Buttons />,
},
{
text: "Pagination",
value: "pagination",
id: "pagination",
content: <Pagination />,
},
{
text: "Containers",
value: "containers",
id: "containers",
content: <Containers />,
},
{
text: "Accordion",
value: "accordion",
id: "accordion",
content: <Accordion />,
},
{
text: "Form",
value: "form",
id: "content",
content: <Form />,
},
{
text: "Dropdowns",
value: "dropdowns",
id: "dropdowns",
content: <Dropdowns />,
},
{
text: "Displays",
value: "displays",
id: "displays",
content: <Displays />,
},
{
text: "Messages",
value: "messages",
id: "messages",
content: <Messages />,
},
{
text: "Timeline",
value: "timeline",
id: "timeline",
content: <TimelineProgress />,
},
{
text: "Progress",
value: "progress",
id: "progress",
content: <Progress />,
},
{
text: "Input",
value: "input",
id: "input",
content: <Input />,
},
{
text: "Tooltip",
value: "tooltip",
id: "tooltip",
content: <Tooltips />,
},
{
text: "Copiable",
value: "copiable",
id: "copiable",
content: <Copiable />,
},
]}
callback={setExample}
currentValue={example}
/>
<StyledCard>
{example === "buttons" && <Buttons />}
{example === "pagination" && <Pagination />}
{example === "containers" && <Containers />}
{example === "accordion" && <Accordion />}
{example === "form" && <Form />}
{example === "dropdowns" && <Dropdowns />}
{example === "displays" && <Displays />}
{example === "messages" && <Messages />}
{example === "timeline" && <TimelineProgress />}
{example === "progress" && <Progress />}
{example === "input" && <Input />}
{example === "tooltip" && <Tooltips />}
{example === "copiable" && <Copiable />}
</StyledCard>
<Button
variant="primary"
className="mt-16"
Expand Down
19 changes: 13 additions & 6 deletions src/examples/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ const Pagination = () => {
numPages={6}
/>
<Tabs
className="w-[500px]"
defaultSelectedKey={"hello"}
panelClassName="bg-klerosUIComponentsLightBlue p-4"
items={[
{ text: "hello", value: 0 },
{ text: "hello", value: 0, id: "hello", content: <p>hello</p> },
{
text: "Telegram",
value: 1,
Icon: Telegram,
id: "telegram",
content: <p>Telegram</p>,
},
{
text: "disabled",
value: 2,
disabled: true,
id: "disabled",
content: <p>Disabled</p>,
},
{ text: "hello1", value: 2, disabled: true },
]}
callback={() => {
// function called when a tab is clicked
}}
currentValue={0}
/>
<Breadcrumb
items={[
Expand Down
135 changes: 52 additions & 83 deletions src/lib/pagination/compact.tsx
Original file line number Diff line number Diff line change
@@ -1,114 +1,83 @@
import React, { ReactNode } from "react";
import styled from "styled-components";
import usePagination from "../../hooks/pagination/use-pagination";
import Arrow from "../../assets/svgs/arrows/circle-left.svg";
import SolidErrorIcon from "../../assets/svgs/status-icons/solid-error.svg";
import { borderBox, button, small, svg } from "../../styles/common-style";
import { cn } from "../../utils";
import { Button, type ButtonProps } from "react-aria-components";
import clsx from "clsx";

const Wrapper = styled.div`
${borderBox}
display: flex;
align-items: center;
justify-content: end;
`;

const StyledSVG = styled.svg``;

const ArrowButton = styled.button`
${button}
height: 24px;
width: 24px;
background: none;
padding: 0;
border-radius: 50%;
& ${StyledSVG} {
${svg}
height: 24px;
width: 24px;
fill: ${(props) =>
props.disabled
? props.theme.klerosUIComponentsStroke
: props.theme.klerosUIComponentsPrimaryBlue};
transition: fill ease
${({ theme }) => theme.klerosUIComponentsTransitionSpeed};
}
:hover:enabled {
& ${StyledSVG} {
fill: ${({ theme }) => theme.klerosUIComponentsSecondaryBlue};
}
}
`;

const StyledLabel = styled.small`
${small}
color: ${(props) => props.theme.klerosUIComponentsPrimaryText};
`;

const LeftArrow = styled(ArrowButton)`
margin-left: 16px;
`;

const RightArrow = styled(ArrowButton)`
margin-left: 8px;
& ${StyledSVG} {
transform: rotate(180deg);
}
`;

const CloseButton = styled(ArrowButton)`
margin-left: 8px;
& ${StyledSVG} {
fill: ${(props) => props.theme.klerosUIComponentsPrimaryBlue};
}
:hover:enabled {
& ${StyledSVG} {
fill: ${({ theme }) => theme.klerosUIComponentsSecondaryBlue};
}
}
`;
const ArrowButton: React.FC<ButtonProps> = ({ className, ...props }) => {
return (
<Button
className={cn(
"h-6 w-6 rounded-full bg-none hover:enabled:cursor-pointer hover:disabled:cursor-default",
"[&>svg]:ease-ease [&>svg]:h-6 [&>svg]:w-6 [&>svg]:transition-[fill]",
":hover:enabled:[&>svg]:fill-klerosUIComponentsSecondaryBlue",
props.isDisabled
? ["[&>svg]:fill-klerosUIComponentsStroke"]
: ["[&>svg]:fill-klerosUIComponentsPrimaryBlue"],
className,
)}
{...props}
>
{props.children}
</Button>
);
};

interface CompactPaginationProps {
currentPage: number;
numPages: number;
callback: (newPage: number) => void;
/** Callback function called when end of pages has been reached */
onCloseOnLastPage?: () => void;
label?: ReactNode;
className?: string;
}

const CompactPagination: React.FC<CompactPaginationProps> = ({
function CompactPagination({
currentPage,
numPages,
callback,
onCloseOnLastPage,
label,
className,
}) => {
}: Readonly<CompactPaginationProps>) {
const [{ incrementPage, decrementPage, minPageReached, maxPageReached }] =
usePagination(currentPage, numPages, callback, onCloseOnLastPage);

return (
<Wrapper {...{ className }}>
<StyledLabel>{label}</StyledLabel>
<LeftArrow disabled={minPageReached} onClick={decrementPage}>
<Arrow className={StyledSVG.styledComponentId} />
</LeftArrow>
<div className={cn("box-border flex items-center justify-end", className)}>
<small className="text-klerosUIComponentsPrimaryText text-sm">
{label}
</small>
<ArrowButton
className={clsx(label && "ml-4")}
isDisabled={minPageReached}
onPress={decrementPage}
>
<Arrow />
</ArrowButton>
{currentPage === numPages && onCloseOnLastPage ? (
<CloseButton onClick={onCloseOnLastPage}>
<SolidErrorIcon className={StyledSVG.styledComponentId} />
</CloseButton>
<ArrowButton className="ml-2" onPress={onCloseOnLastPage}>
<SolidErrorIcon
className={clsx(
"fill-klerosUIComponentsPrimaryBlue",
"hover:enabled:fill-klerosUIComponentsSecondaryBlue",
)}
/>
</ArrowButton>
) : (
<RightArrow disabled={maxPageReached} onClick={incrementPage}>
<Arrow className={StyledSVG.styledComponentId} />
</RightArrow>
<ArrowButton
className={"ml-2"}
isDisabled={maxPageReached}
onPress={incrementPage}
>
<Arrow className="rotate-180" />
</ArrowButton>
)}
</Wrapper>
</div>
);
};
}

export default CompactPagination;
Loading