Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InfoCard and Stud components for landing pages #1737

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/eight-seas-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@theguild/components': minor
---

Add InfoCard and Stud components for landing pages'
2 changes: 2 additions & 0 deletions packages/components/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ export * from './decorations';
export * from './call-to-action';
export * from './cookies-consent';
export * from './heading';
export * from './info-card';
export * from './stud';
20 changes: 20 additions & 0 deletions packages/components/src/components/info-card.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Meta, StoryObj } from '@storybook/react';
import { hiveThemeDecorator } from '../../../../.storybook/hive-theme-decorator';
import { AccountBox } from './icons';
import { InfoCard, InfoCardProps } from './info-card';

export default {
title: 'Components/InfoCard',
component: InfoCard,
decorators: [hiveThemeDecorator],
} satisfies Meta<InfoCardProps>;

export const Default: StoryObj<InfoCardProps> = {
args: {
Comment on lines +12 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export const Default: StoryObj<InfoCardProps> = {
args: {
export const Default: StoryObj<InfoCardProps> = {
name: 'InfoCard',
args: {

like in Stud
image

to not have a list? or do you plan to add more stories here?

icon: <AccountBox />,
as: 'div',
heading: 'Customizable User Roles and Permissions',
children:
'Control user access with detailed, role-based permissions for enhanced security and flexibility.',
},
};
26 changes: 26 additions & 0 deletions packages/components/src/components/info-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ReactNode } from 'react';
import { cn } from '../cn';
import { Stud } from './stud';

export interface InfoCardProps extends React.HTMLAttributes<HTMLElement> {
icon: ReactNode;
heading: ReactNode;
as?: 'div' | 'li';
}

export function InfoCard({
as: Root = 'div',
icon,
heading,
className,
children,
...rest
}: InfoCardProps) {
return (
<Root className={cn('bg-beige-100 p-6 md:p-12', className)} {...rest}>
<Stud>{icon}</Stud>
<h3 className="mt-4 text-xl font-medium leading-[1.4] text-green-1000 md:mt-6">{heading}</h3>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<h3 className="mt-4 text-xl font-medium leading-[1.4] text-green-1000 md:mt-6">{heading}</h3>
<h3 className="mt-4 text-xl font-medium leading-[1.4] text-green-1000 md:mt-6">{heading}</h3>

what's 1.4 stay for I guess it's 18px?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not 18px because it's text-xl. Just 1.4 of font-size. Copied it from Figma.

We can prolly remove it, as it's 20px * 1.4 == 28px, and Tailwind's text-xl includes line-height: 1.75rem which, with 16px html font-size is also 28px.

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh thx, and yes you right, you can remove it, also for the future there is shorthand text-xl/[value-of-your-leading]

<p className="mt-2 text-green-800 md:mt-4">{children}</p>
</Root>
);
}
17 changes: 17 additions & 0 deletions packages/components/src/components/stud.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Meta, StoryObj } from '@storybook/react';
import { hiveThemeDecorator } from '../../../../.storybook/hive-theme-decorator';
import { RightCornerIcon } from './icons';
import { Stud, StudProps } from './stud';

export default {
title: 'Components/Stud',
component: Stud,
decorators: [hiveThemeDecorator],
} satisfies Meta<StudProps>;

export const Default: StoryObj<StudProps> = {
name: 'Stud',
args: {
children: <RightCornerIcon />,
},
};
14 changes: 14 additions & 0 deletions packages/components/src/components/stud.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { cn } from '../cn';

export interface StudProps extends React.HTMLAttributes<HTMLElement> {}
export function Stud(props: StudProps) {
return (
<div
{...props}
className={cn(
'w-fit rounded-lg bg-[linear-gradient(135deg,#68A8B6,#3B736A)] p-[9px] text-white',
props.className,
)}
/>
);
}
Loading