-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
442 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export interface InputAddonProps { | ||
children: React.ReactNode | ||
border?: 'none' | 'left' | 'right' | ||
isGrey?: boolean | ||
} | ||
|
||
export const InputAddon = ({ children, ...props }: InputAddonProps) => { | ||
const { border, isGrey } = props | ||
|
||
let greyBg = '' | ||
let hasBorder = '' | ||
|
||
switch (border) { | ||
case 'left': | ||
greyBg = isGrey ? 'rounded-r-md bg-cu-black-50' : '' | ||
hasBorder = `border-l border-cu-black-200 ${greyBg}` | ||
break | ||
case 'right': | ||
greyBg = isGrey ? 'rounded-l-md bg-cu-black-50' : '' | ||
hasBorder = `border-r border-cu-black-200 ${greyBg}` | ||
break | ||
|
||
default: | ||
greyBg = '' | ||
hasBorder = '' | ||
break | ||
} | ||
|
||
return <span className={`px-4 flex items-center ${hasBorder}`}>{children}</span> | ||
} | ||
|
||
export default InputAddon |
31 changes: 31 additions & 0 deletions
31
lib/components/Loaders/CalendarLoader/CalendarLoader.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { CalendarLoader } from './CalendarLoader' | ||
import { Section } from '../../../layouts/Section/Section' | ||
import React from 'react' | ||
|
||
const meta: Meta<typeof CalendarLoader> = { | ||
title: 'Components/Load Screens/Calendar Loader', | ||
component: CalendarLoader, | ||
tags: ['autodocs'], | ||
parameters: { | ||
controls: { | ||
sort: 'requiredFirst', | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof CalendarLoader> | ||
|
||
export const Primary: Story = { | ||
args: { | ||
showClearButton: true, | ||
}, | ||
render: (args) => { | ||
return ( | ||
<Section> | ||
<CalendarLoader {...args} /> | ||
</Section> | ||
) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { format, getDay, isBefore, startOfToday, eachDayOfInterval, endOfMonth, parse } from 'date-fns' | ||
import { ButtonLoader } from '../ButtonLoader/ButtonLoader' | ||
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline' | ||
import { useState } from 'react' | ||
|
||
const styles = { | ||
prevNextArrows: `flex items-center justify-center flex-none p-2 text-cu-black-800 hover:text-cu-red`, | ||
calendarGrid: `grid grid-cols-7 gap-px mt-4 text-center`, | ||
element: `w-8 h-8 bg-cu-black-200 rounded-full `, | ||
} | ||
|
||
const classNames = (...classes: (string | boolean)[]) => { | ||
return classes.filter(Boolean).join(' ') | ||
} | ||
|
||
export interface CalendarLoaderProps { | ||
showClearButton?: boolean | ||
} | ||
|
||
export const CalendarLoader = ({ showClearButton }: CalendarLoaderProps) => { | ||
const today = startOfToday() | ||
const [currentMonth] = useState(format(today, 'MMM-yyyy')) | ||
const firstDayCurrentMonth = parse(currentMonth, 'MMM-yyyy', new Date()) | ||
const colStartClasses = ['', 'col-start-2', 'col-start-3', 'col-start-4', 'col-start-5', 'col-start-6', 'col-start-7'] | ||
const days = eachDayOfInterval({ | ||
start: firstDayCurrentMonth, | ||
end: endOfMonth(firstDayCurrentMonth), | ||
}) | ||
|
||
return ( | ||
<> | ||
<div className="animate-pulse"> | ||
<div className="cu-calendar cu-component not-prose"> | ||
<div className="flex items-center py-2 mb-6 bg-white border rounded-lg border-cu-black-100"> | ||
<button type="button" className={`${styles.prevNextArrows}`}> | ||
<span className="text-base sr-only">Previous month</span> | ||
<ChevronLeftIcon className="w-5 h-5" aria-hidden="true" /> | ||
</button> | ||
<div className="flex items-center justify-center mx-auto"> | ||
{/* {format(firstDayCurrentMonth, 'MMMM yyyy')} */} | ||
<span className="block h-6 w-48 rounded-md bg-cu-black-200"></span> | ||
</div> | ||
<button type="button" className={`${styles.prevNextArrows}`}> | ||
<span className="text-base sr-only">Next month</span> | ||
<ChevronRightIcon className="w-5 h-5" aria-hidden="true" /> | ||
</button> | ||
</div> | ||
|
||
<div className={`${styles.calendarGrid} text-xs text-cu-black-600`}> | ||
<div>S</div> | ||
<div>M</div> | ||
<div>T</div> | ||
<div>W</div> | ||
<div>T</div> | ||
<div>F</div> | ||
<div>S</div> | ||
</div> | ||
|
||
<div | ||
className={`${styles.calendarGrid} isolate overflow-hidden rounded-lg border border-cu-black-100 bg-cu-black-50 text-sm`} | ||
> | ||
{days.map((day, dayIdx) => ( | ||
<div | ||
key={day.toString()} | ||
className={classNames(dayIdx === 0 && colStartClasses[getDay(day)], 'bg-white py-2')} | ||
> | ||
<button type="button" disabled={isBefore(day, today)}> | ||
<div className={styles.element}></div> | ||
</button> | ||
|
||
<div className="w-1 h-1 mx-auto mt-1"></div> | ||
</div> | ||
))} | ||
</div> | ||
{showClearButton && ( | ||
<div className="mt-4 flex justify-center items-center"> | ||
<ButtonLoader number={1} isSmall={true} /> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
lib/components/Loaders/EventLoader/EventLoader.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { EventLoader } from './EventLoader' | ||
|
||
const meta: Meta<typeof EventLoader> = { | ||
title: 'Components/Load Screens/Event Loader', | ||
component: EventLoader, | ||
tags: ['autodocs'], | ||
parameters: { | ||
controls: { | ||
sort: 'requiredFirst', | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof EventLoader> | ||
|
||
export const Default: Story = {} | ||
Default.args = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Column, StackedList, Aside } from '../../../main' | ||
import { ListingNewsLoader } from '../ListingLoader/ListingNewsLoader' | ||
import { PaginationLoader } from '../PaginationLoader/PaginationLoader' | ||
import { CalendarLoader } from '../CalendarLoader/CalendarLoader' | ||
|
||
export interface EventLoaderProps { | ||
pageCount?: number | ||
showClearButton?: boolean | ||
} | ||
|
||
export const EventLoader = ({ pageCount = 5, showClearButton = false }: EventLoaderProps) => { | ||
return ( | ||
<> | ||
<Column cols="2/3" maxWidth="7xl"> | ||
<Column.Content> | ||
<StackedList cols="2"> | ||
<ListingNewsLoader /> | ||
<ListingNewsLoader /> | ||
<ListingNewsLoader /> | ||
<ListingNewsLoader /> | ||
<ListingNewsLoader /> | ||
<ListingNewsLoader /> | ||
</StackedList> | ||
<PaginationLoader pageCount={pageCount} /> | ||
</Column.Content> | ||
|
||
<Aside isSticky topSpace={105}> | ||
<CalendarLoader showClearButton={showClearButton} /> | ||
</Aside> | ||
</Column> | ||
</> | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
lib/components/Loaders/PaginationLoader/PaginationLoader.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { PaginationLoader } from './PaginationLoader' | ||
import { Section } from '../../../layouts/Section/Section' | ||
import React from 'react' | ||
|
||
const meta: Meta<typeof PaginationLoader> = { | ||
title: 'Components/Load Screens/Pagination Loader', | ||
component: PaginationLoader, | ||
tags: ['autodocs'], | ||
parameters: { | ||
controls: { | ||
sort: 'requiredFirst', | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof PaginationLoader> | ||
|
||
export const Primary: Story = { | ||
args: { | ||
hasBorder: true, | ||
pageCount: 5, | ||
}, | ||
render: (args) => { | ||
return ( | ||
<Section> | ||
<PaginationLoader {...args} /> | ||
</Section> | ||
) | ||
}, | ||
} |
Oops, something went wrong.