Move all components to Astro
This commit is contained in:
parent
4b95c529df
commit
1bb8587933
34 changed files with 98 additions and 148 deletions
15
src/components/atoms/button.astro
Normal file
15
src/components/atoms/button.astro
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
export interface Props extends astroHTML.JSX.ButtonHTMLAttributes {}
|
||||||
|
|
||||||
|
const props = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
{...props}
|
||||||
|
class:list={[
|
||||||
|
'inline-flex items-center px-4 h-10 text-base font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 active:translate-y-px focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500',
|
||||||
|
props.class,
|
||||||
|
]}
|
||||||
|
><slot />
|
||||||
|
</button>
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
||||||
|
|
||||||
import * as C from './button';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
title: 'Button',
|
|
||||||
component: C.Button,
|
|
||||||
argTypes: {
|
|
||||||
onClick: { action: 'onClick' },
|
|
||||||
},
|
|
||||||
} as ComponentMeta<typeof C.Button>;
|
|
||||||
|
|
||||||
export const Button: ComponentStory<typeof C.Button> = (args) => <C.Button {...args} />;
|
|
||||||
|
|
||||||
Button.args = {
|
|
||||||
children: 'Button text',
|
|
||||||
};
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import clsx from 'clsx';
|
|
||||||
import type { ComponentPropsWithoutRef } from 'react';
|
|
||||||
|
|
||||||
interface ButtonProps extends ComponentPropsWithoutRef<'button'> {}
|
|
||||||
|
|
||||||
export const Button = ({ className, ...props }: ButtonProps) => (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={clsx(
|
|
||||||
'inline-flex items-center px-4 h-10 text-base font-medium rounded-md shadow-sm text-white bg-primary-600 hover:bg-primary-700 active:translate-y-px focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500',
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { Button } from './button';
|
|
||||||
13
src/components/atoms/labelled-value.astro
Normal file
13
src/components/atoms/labelled-value.astro
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
export interface Props extends astroHTML.JSX.HTMLAttributes {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { label, value, ...props } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<div {...props} class:list={['text-base space-x-1', props.class]}>
|
||||||
|
<span class="font-medium text-gray-700">{label}:</span>
|
||||||
|
<span class="font-normal text-gray-500">{value}</span>
|
||||||
|
</div>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { LabelledValue } from './labelled-value';
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
||||||
|
|
||||||
import * as C from './labelled-value';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
title: 'LabelledValue',
|
|
||||||
component: C.LabelledValue,
|
|
||||||
} as ComponentMeta<typeof C.LabelledValue>;
|
|
||||||
|
|
||||||
export const LabelledValue: ComponentStory<typeof C.LabelledValue> = (args) => <C.LabelledValue {...args} />;
|
|
||||||
|
|
||||||
LabelledValue.args = {
|
|
||||||
label: 'Label',
|
|
||||||
children: 'Value',
|
|
||||||
};
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
import clsx from 'clsx';
|
|
||||||
import type { ComponentPropsWithoutRef } from 'react';
|
|
||||||
|
|
||||||
interface LabelledValueProps extends ComponentPropsWithoutRef<'div'> {
|
|
||||||
label: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const LabelledValue = ({ label, children, className, ...props }: LabelledValueProps) => (
|
|
||||||
<div className={clsx('text-base space-x-1', className)} {...props}>
|
|
||||||
<span className="font-medium text-gray-700">{label}:</span>
|
|
||||||
<span className="font-normal text-gray-500">{children}</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
7
src/components/atoms/section-card.astro
Normal file
7
src/components/atoms/section-card.astro
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
export interface Props extends astroHTML.JSX.HTMLAttributes {}
|
||||||
|
|
||||||
|
const props = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<div {...props} class:list={['p-8 bg-white rounded-2xl shadow-lg', props.class]}><slot /></div>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { SectionCard } from './section-card';
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
||||||
|
|
||||||
import * as C from './section-card';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
title: 'SectionCard',
|
|
||||||
component: C.SectionCard,
|
|
||||||
} as ComponentMeta<typeof C.SectionCard>;
|
|
||||||
|
|
||||||
export const SectionCard: ComponentStory<typeof C.SectionCard> = (args) => <C.SectionCard {...args} />;
|
|
||||||
|
|
||||||
SectionCard.args = {
|
|
||||||
children: 'Card content',
|
|
||||||
};
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import clsx from 'clsx';
|
|
||||||
import type { ComponentPropsWithoutRef } from 'react';
|
|
||||||
|
|
||||||
interface SectionCardProps extends ComponentPropsWithoutRef<'div'> {}
|
|
||||||
|
|
||||||
export const SectionCard = ({ className, ...props }: SectionCardProps) => (
|
|
||||||
<div className={clsx('p-8 bg-white rounded-2xl shadow-lg', className)} {...props} />
|
|
||||||
);
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import clsx from 'clsx';
|
---
|
||||||
import type { ComponentPropsWithoutRef } from 'react';
|
|
||||||
|
|
||||||
type TypographyVariant =
|
type TypographyVariant =
|
||||||
| 'item-title'
|
| 'item-title'
|
||||||
| 'item-subtitle'
|
| 'item-subtitle'
|
||||||
|
|
@ -12,10 +10,6 @@ type TypographyVariant =
|
||||||
| 'section-subtitle'
|
| 'section-subtitle'
|
||||||
| 'paragraph';
|
| 'paragraph';
|
||||||
|
|
||||||
interface TypographyProps extends ComponentPropsWithoutRef<'div'> {
|
|
||||||
variant?: TypographyVariant;
|
|
||||||
}
|
|
||||||
|
|
||||||
const variantToElement = {
|
const variantToElement = {
|
||||||
'main-title': 'h1',
|
'main-title': 'h1',
|
||||||
'main-subtitle': 'h2',
|
'main-subtitle': 'h2',
|
||||||
|
|
@ -40,8 +34,12 @@ const variantToClassName = {
|
||||||
paragraph: 'text-base leading-relaxed font-normal text-gray-500',
|
paragraph: 'text-base leading-relaxed font-normal text-gray-500',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Typography = ({ variant = 'paragraph', className, ...props }: TypographyProps) => {
|
export interface Props extends Omit<astroHTML.JSX.HTMLAttributes, 'slot'> {
|
||||||
const Element = variantToElement[variant];
|
variant?: TypographyVariant;
|
||||||
|
}
|
||||||
|
|
||||||
return <Element className={clsx(variantToClassName[variant], className)} {...props} />;
|
const { variant = 'paragraph', ...props } = Astro.props;
|
||||||
};
|
const Element = variantToElement[variant];
|
||||||
|
---
|
||||||
|
|
||||||
|
<Element {...props} class:list={[variantToClassName[variant], props.class]}><slot /></Element>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { Typography } from './typography';
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
||||||
|
|
||||||
import * as C from './typography';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
title: 'Typography',
|
|
||||||
component: C.Typography,
|
|
||||||
} as ComponentMeta<typeof C.Typography>;
|
|
||||||
|
|
||||||
export const Typography: ComponentStory<typeof C.Typography> = (args) => <C.Typography {...args} />;
|
|
||||||
|
|
||||||
Typography.args = {
|
|
||||||
children: 'Typography text',
|
|
||||||
variant: 'paragraph',
|
|
||||||
};
|
|
||||||
8
src/components/sections/experience-section.astro
Normal file
8
src/components/sections/experience-section.astro
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import SectionCard from '@/atoms/section-card.astro';
|
||||||
|
import type { ExperienceSection } from '@/types/experience-section';
|
||||||
|
|
||||||
|
export interface Props extends ExperienceSection {}
|
||||||
|
---
|
||||||
|
|
||||||
|
<SectionCard>Experience section</SectionCard>
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import { SectionCard } from '@/atoms/section-card';
|
|
||||||
import type { ExperienceSection as ExperienceSectionProps } from '@/types/experience-section';
|
|
||||||
|
|
||||||
export const ExperienceSection = (props: ExperienceSectionProps) => <SectionCard>Experience section</SectionCard>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { ExperienceSection } from './experience-section';
|
|
||||||
8
src/components/sections/favorites-section.astro
Normal file
8
src/components/sections/favorites-section.astro
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import SectionCard from '@/atoms/section-card.astro';
|
||||||
|
import type { FavoritesSection } from '@/types/favorites-section';
|
||||||
|
|
||||||
|
export interface Props extends FavoritesSection {}
|
||||||
|
---
|
||||||
|
|
||||||
|
<SectionCard>Favorites section</SectionCard>
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import { SectionCard } from '@/atoms/section-card';
|
|
||||||
import type { FavoritesSection as FavoritesSectionProps } from '@/types/favorites-section';
|
|
||||||
|
|
||||||
export const FavoritesSection = (props: FavoritesSectionProps) => <SectionCard>Favorites section</SectionCard>;
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { FavoritesSection } from './favorites-section';
|
|
||||||
8
src/components/sections/main-section.astro
Normal file
8
src/components/sections/main-section.astro
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import SectionCard from '@/atoms/section-card.astro';
|
||||||
|
import type { MainSection } from '@/types/main-section';
|
||||||
|
|
||||||
|
export interface Props extends MainSection {}
|
||||||
|
---
|
||||||
|
|
||||||
|
<SectionCard>Main section</SectionCard>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { MainSection } from './main-section';
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import { SectionCard } from '@/atoms/section-card';
|
|
||||||
import type { MainSection as MainSectionProps } from '@/types/main-section';
|
|
||||||
|
|
||||||
export const MainSection = (props: MainSectionProps) => <SectionCard>Main section</SectionCard>;
|
|
||||||
8
src/components/sections/portfolio-section.astro
Normal file
8
src/components/sections/portfolio-section.astro
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import SectionCard from '@/atoms/section-card.astro';
|
||||||
|
import type { PortfolioSection } from '@/types/portfolio-section';
|
||||||
|
|
||||||
|
export interface Props extends PortfolioSection {}
|
||||||
|
---
|
||||||
|
|
||||||
|
<SectionCard>Portfolio section</SectionCard>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { PortfolioSection } from './portfolio-section';
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import { SectionCard } from '@/atoms/section-card';
|
|
||||||
import type { PortfolioSection as PortfolioSectionProps } from '@/types/portfolio-section';
|
|
||||||
|
|
||||||
export const PortfolioSection = (props: PortfolioSectionProps) => <SectionCard>Portfolio section</SectionCard>;
|
|
||||||
8
src/components/sections/skills-section.astro
Normal file
8
src/components/sections/skills-section.astro
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import SectionCard from '@/atoms/section-card.astro';
|
||||||
|
import type { SkillsSection } from '@/types/skills-section';
|
||||||
|
|
||||||
|
export interface Props extends SkillsSection {}
|
||||||
|
---
|
||||||
|
|
||||||
|
<SectionCard>Skills section</SectionCard>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { SkillsSection } from './skills-section';
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import { SectionCard } from '@/atoms/section-card';
|
|
||||||
import type { SkillsSection as SkillsSectionProps } from '@/types/skills-section';
|
|
||||||
|
|
||||||
export const SkillsSection = (props: SkillsSectionProps) => <SectionCard>Skills section</SectionCard>;
|
|
||||||
8
src/components/sections/testimonials-section.astro
Normal file
8
src/components/sections/testimonials-section.astro
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
import SectionCard from '@/atoms/section-card.astro';
|
||||||
|
import type { TestimonialsSection } from '@/types/testimonials-section';
|
||||||
|
|
||||||
|
export interface Props extends TestimonialsSection {}
|
||||||
|
---
|
||||||
|
|
||||||
|
<SectionCard>Testimonials section</SectionCard>
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { TestimonialsSection } from './testimonials-section';
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
import { SectionCard } from '@/atoms/section-card';
|
|
||||||
import type { TestimonialsSection as TestimonialsSectionProps } from '@/types/testimonials-section';
|
|
||||||
|
|
||||||
export const TestimonialsSection = (props: TestimonialsSectionProps) => <SectionCard>Testimonials section</SectionCard>;
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
import { ExperienceSection } from '@/sections/experience';
|
import ExperienceSection from '@/sections/experience-section.astro';
|
||||||
import { FavoritesSection } from '@/sections/favorites';
|
import FavoritesSection from '@/sections/favorites-section.astro';
|
||||||
import { MainSection } from '@/sections/main';
|
import MainSection from '@/sections/main-section.astro';
|
||||||
import { PortfolioSection } from '@/sections/portfolio';
|
import PortfolioSection from '@/sections/portfolio-section.astro';
|
||||||
import { SkillsSection } from '@/sections/skills';
|
import SkillsSection from '@/sections/skills-section.astro';
|
||||||
import { TestimonialsSection } from '@/sections/testimonials';
|
import TestimonialsSection from '@/sections/testimonials-section.astro';
|
||||||
import { data } from '../data';
|
import { data } from '../data';
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue