Skip to content

Commit

Permalink
Merge branch 'main' of github.com:codedazur/toolkit into fix/parallax…
Browse files Browse the repository at this point in the history
…-performance
  • Loading branch information
thijsdaniels committed Oct 18, 2023
2 parents 43e902b + 8bae49d commit 0fb1ad3
Show file tree
Hide file tree
Showing 59 changed files with 1,053 additions and 416 deletions.
2 changes: 1 addition & 1 deletion apps/infrastructure/constructs/ToolkitSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ToolkitSite extends StaticSite {
constructor(
scope: Construct,
id: string,
{ subdomain, ...props }: ToolkitSiteProps
{ subdomain, ...props }: ToolkitSiteProps,
) {
super(scope, id, {
...props,
Expand Down
40 changes: 21 additions & 19 deletions apps/storybook/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ export interface ButtonProps extends BaseButtonProps {
foreground?: keyof DefaultTheme["colors"] | Color;
}

export const Button = styled(BaseButton)<ButtonProps>(
({ theme, background = "primary", foreground }) => {
const fg: Color | undefined =
typeof foreground === "string" ? theme.colors[foreground] : foreground;
export const Button = styled(BaseButton)<ButtonProps>(({
theme,
background = "primary",
foreground,
}) => {
const fg: Color | undefined =
typeof foreground === "string" ? theme.colors[foreground] : foreground;

const bg: Color =
typeof background === "string" ? theme.colors[background]! : background;
const bg: Color =
typeof background === "string" ? theme.colors[background]! : background;

return css`
color: ${(fg ?? highlight(bg, 1)).toString()};
background-color: ${bg.toString()};
border-color: ${bg.toString()};
return css`
color: ${(fg ?? highlight(bg, 1)).toString()};
background-color: ${bg.toString()};
border-color: ${bg.toString()};
:focus,
:active,
:hover {
background-color: ${highlight(bg).toString()};
border-color: ${highlight(bg).toString()};
}
`;
}
);
:focus,
:active,
:hover {
background-color: ${highlight(bg).toString()};
border-color: ${highlight(bg).toString()};
}
`;
});
5 changes: 3 additions & 2 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"styled-components": "^5.3.6",
"yaml": "^2.3.1"
"yaml": "^2.3.1",
"date-fns": "^2.30.0"
},
"devDependencies": {
"@babel/preset-env": "^7.22.9",
Expand All @@ -42,6 +43,6 @@
"@storybook/testing-library": "^0.2.0",
"@types/color": "^3.0.3",
"storybook": "^7.2.0",
"vite": "4.4.9"
"vite": "4.4.11"
}
}
67 changes: 67 additions & 0 deletions apps/storybook/stories/react-date-picker/components/Day.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { transparent } from "@codedazur/react-components";
import styled, { css } from "styled-components";

interface DayProps {
isInActiveMonth: boolean;
isInSelectedRange: boolean;
isInFocusedRange: boolean;
isSelected: boolean;
isFirstDate: boolean;
isLastDate: boolean;
}

export const Day = styled.div.attrs<DayProps>((props) => ({
background: props.isSelected ? "primary" : transparent,
foreground: "foreground",
...props,
}))<DayProps>`
position: relative;
width: 100%;
padding: 0.25rem;
transition: 0.2s;
border: none;
border-radius: 50%;
${({ theme, isFirstDate, isLastDate, isInFocusedRange, isInSelectedRange }) =>
(isFirstDate || isLastDate || isInFocusedRange || isInSelectedRange) &&
css`
:before {
content: "";
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: ${theme.colors.primary.alpha(0.25).toString()};
${isFirstDate &&
css`
border-top-left-radius: 50%;
border-bottom-left-radius: 50%;
`}
${isLastDate &&
css`
border-top-right-radius: 50%;
border-bottom-right-radius: 50%;
`}
}
`}
${({ isInSelectedRange }) =>
!isInSelectedRange &&
css`
:hover {
:before {
border-top-right-radius: 50%;
border-bottom-right-radius: 50%;
}
}
`}
${({ isInActiveMonth }) =>
!isInActiveMonth &&
css`
opacity: 0.25;
`}
`;
38 changes: 38 additions & 0 deletions apps/storybook/stories/react-date-picker/components/Days.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
Grid,
GridItem,
UseDatePickerResult,
} from "@codedazur/react-components";
import { FunctionComponent } from "react";
import { Day } from "./Day";

interface MonthProps {
days: UseDatePickerResult["month"]["days"];
onDayClick?: (date: Date) => void;
}

export const Days: FunctionComponent<MonthProps> = ({ days, onDayClick }) => (
<Grid columns={7}>
{days.map((day, index) => (
<GridItem key={index}>
{day !== null && (
<Day
type="button"
isInFocusedRange={day.isInFocusedRange}
isInSelectedRange={day.isInSelectedRange}
isSelected={day.isSelected}
isFirstDate={day.isFirstDate}
isLastDate={day.isLastDate}
isInActiveMonth={day.isInActiveMonth}
disabled={day.isDisabled}
onClick={onDayClick ? () => onDayClick(day.date) : day.onClick}
onMouseEnter={day.onMouseEnter}
onMouseLeave={day.onMouseLeave}
>
{day.label}
</Day>
)}
</GridItem>
))}
</Grid>
);
33 changes: 33 additions & 0 deletions apps/storybook/stories/react-date-picker/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
ChevronLeftIcon,
ChevronRightIcon,
IconButton,
Padding,
Row,
} from "@codedazur/react-components";
import { FunctionComponent, MouseEventHandler } from "react";
import { Monospace } from "../../../components/Monospace";

interface NavigationProps {
label?: string;
onNextClick?: MouseEventHandler;
onPreviousClick?: MouseEventHandler;
}

export const Navigation: FunctionComponent<NavigationProps> = ({
label = "",
onNextClick,
onPreviousClick,
}) => (
<Padding all="0.5rem">
<Row justify="space-between" align="center">
<IconButton onClick={onPreviousClick}>
<ChevronLeftIcon />
</IconButton>
<Monospace>{label}</Monospace>
<IconButton onClick={onNextClick}>
<ChevronRightIcon />
</IconButton>
</Row>
</Padding>
);
27 changes: 27 additions & 0 deletions apps/storybook/stories/react-date-picker/components/Weekdays.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
EdgeInset,
Expanded,
Grid,
GridItem,
UseDatePickerResult,
} from "@codedazur/react-components";
import { FunctionComponent } from "react";
import { Monospace } from "../../../components/Monospace";

interface WeekdaysProps {
weekdays: UseDatePickerResult["month"]["weekdays"];
}

export const Weekdays: FunctionComponent<WeekdaysProps> = ({ weekdays }) => (
<Grid columns={7}>
{weekdays.map(({ label }, index) => (
<GridItem key={index}>
<EdgeInset vertical="0.5rem">
<Expanded>
<Monospace align="center">{label}</Monospace>
</Expanded>
</EdgeInset>
</GridItem>
))}
</Grid>
);
Loading

0 comments on commit 0fb1ad3

Please sign in to comment.