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

Created custom button variants #132

Merged
merged 37 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fef4b0c
Created custom button variants
ryandotfurrer Apr 13, 2024
882c6c4
Merge branch 'develop' into 124-create-custom-button-component
ryandotfurrer Apr 13, 2024
c1e7f36
Removed unused button variant
ryandotfurrer Apr 13, 2024
9b1944a
Removed bad imports and references to Supabase from the Storybook Dev…
ryandotfurrer Apr 13, 2024
25f45be
Merge branch 'develop' into 124-create-custom-button-component
shashilo Apr 15, 2024
de6874b
Merge branch 'develop' of https://github.com/LetsGetTechnical/gridiro…
ryandotfurrer Apr 17, 2024
a3cb2f5
Resolve merge conflic so I could pull the latest develop branch locally
ryandotfurrer Apr 17, 2024
7873597
Revert `./page.tsx` changes
ryandotfurrer Apr 17, 2024
23cda40
Remove note in Developer Guide as per Shashi's request.
ryandotfurrer Apr 17, 2024
0beb9fe
Rename
ryandotfurrer Apr 17, 2024
ad0b008
Rename existing Button in Storybooks "CustomButton" to coincide with …
ryandotfurrer Apr 17, 2024
1c60d12
Rename associated Storybook files with 'CustomButton'
ryandotfurrer Apr 17, 2024
13d3223
Create Storybook entry for Button.
ryandotfurrer Apr 17, 2024
150c876
Fix Vercel deployment issues
ryandotfurrer Apr 17, 2024
c69a735
Create jest test for default button component. Can be expanded on for…
ryandotfurrer Apr 19, 2024
1ed9d61
Remove traces of
ryandotfurrer Apr 19, 2024
d5b02f1
Moved from usint Jest for testing to React Testing Library (RTL).
ryandotfurrer Apr 19, 2024
64241c1
Fix issues stopping me from successfully running
ryandotfurrer Apr 19, 2024
3360617
Reconfigured prettier config as I was getting an error saying it was …
ryandotfurrer Apr 19, 2024
6084d63
Rewrite path to Button component in test file using relative pathing
ryandotfurrer Apr 19, 2024
2b72175
Rename to
ryandotfurrer Apr 20, 2024
8c3f927
Rename to so it is using TypeScript rather than JavaScript
ryandotfurrer Apr 20, 2024
fccff99
Consolidate component files (stories, tests, components) into subfold…
ryandotfurrer Apr 20, 2024
86e4dfc
.
ryandotfurrer Apr 20, 2024
fd4f662
Fixed storybook deployment issue
ryandotfurrer Apr 20, 2024
5200f39
Remove authbutton component
ryandotfurrer Apr 21, 2024
98d9f94
Remove commented out code in
ryandotfurrer Apr 21, 2024
fb831e0
Merge branch 'develop' of https://github.com/LetsGetTechnical/gridiro…
ryandotfurrer Apr 24, 2024
042d0b2
Merge branch 'develop' into 124-create-custom-button-component
ryandotfurrer Apr 24, 2024
8710a45
Merge branch '124-create-custom-button-component' of https://github.c…
ryandotfurrer Apr 24, 2024
e3bf2aa
Remove references to AuthButton
ryandotfurrer Apr 24, 2024
98f4bb7
Remove unneeded eslint dependencies
ryandotfurrer Apr 24, 2024
8243d70
Update stories/Components/Header.tsx
ryandotfurrer Apr 24, 2024
ae7159d
Remove mentions of supabae in the Developer Guide
ryandotfurrer Apr 25, 2024
0ea6cfb
Merge branch 'develop' into 124-create-custom-button-component
ryandotfurrer Apr 25, 2024
bc71101
Resolve merge conflicts
ryandotfurrer Apr 25, 2024
65f6c55
Run pnpm i
ryandotfurrer Apr 25, 2024
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
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.github/
*.config.js
.prettierrc.js
*.json
*.md
5 changes: 1 addition & 4 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import AuthButton from '../components/AuthButton';

export default function Index() {
return (
<div className="flex flex-col items-center justify-center flex-1 w-full">
<nav className="flex flex-col items-center justify-center flex-1 w-full">
<p>Gridiron Survivor</p>
<AuthButton />
<p className='pb-4'>Gridiron Survivor</p>
</nav>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions components/AuthButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ export default function AuthButton() {
}

// export default AuthButton;

45 changes: 0 additions & 45 deletions components/CustomButton.tsx

This file was deleted.

45 changes: 0 additions & 45 deletions components/Test.tsx

This file was deleted.

42 changes: 42 additions & 0 deletions components/button/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from '@storybook/react';
import { fn } from "@storybook/test";
import { Button } from './Button';

//👇 This default export determines where your story goes in the story list
const meta: Meta<typeof Button> = {
title: "Components/Button",
component: Button,
tags: ["autodocs"],
parameters: {
docs: {
description: {
component: `Primary UI component for user interaction.`,
},
},
},
argTypes: {
size: {
options: ['default', 'sm', 'lg', 'icon'],
control: {type: 'radio'},
description: "How large should the button be?",
},
variant: {
description: 'Which type of button?'
},
label: { description: "Button text content" },
onClick: { description: "Click handler" },
},
args: { onClick: fn() },
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
variant: 'default',
size: 'default',
label: "Click Me",
},

};
9 changes: 9 additions & 0 deletions components/button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { Button } from "./Button";

it('should render a button with no variant defined', () => {
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
render(<Button />)
const defaultButton = screen.getByRole('button')
expect(defaultButton).toHaveClass('bg-orange-600')
})
23 changes: 14 additions & 9 deletions components/ui/button.tsx → components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { LucideProps } from "lucide-react";

import { cn } from '../../lib/utils';

Expand All @@ -9,13 +10,13 @@ const buttonVariants = cva(
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
default: "bg-orange-600 text-white hover:bg-orange-600/90",
outline:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
Expand All @@ -37,20 +38,24 @@ export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
label?: string;
icon?: React.ComponentType<LucideProps & { className?: string }>;
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
({ className, variant, size, asChild, label, icon, ...props }, ref) => {
return (
<Comp
<button
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
>
<Slot />
{label}
</button>
);
}
);
Button.displayName = "Button";

export { Button, buttonVariants };
export { Button, buttonVariants };
2 changes: 2 additions & 0 deletions package.json
shashilo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"encoding": "^0.1.13",
"eslint": "^9.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is ESLINT being added to this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps it is because I've been doing git pull origin develop every day I continued working on this? Other than that, I've only used pnpm install when I originally created the branch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you are pulling in the latest from develop it would not cause an update. This is saying that your changes differ from what's in develop today. You may have a local setting for npm or pnpm that forces an update when you install. In @chris-nowicki's PR, there was no usage of this package. Do we need it? https://github.com/LetsGetTechnical/gridiron-survivor/pull/123/files

"eslint-config-next": "14.1.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14",
shashilo marked this conversation as resolved.
Show resolved Hide resolved
"storybook": "^8.0.4",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
Expand Down
Loading
Loading