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

Drop v2: Slider component #5473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions packages/web/app/src/components/ui/slider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from "react"

Check failure on line 1 in packages/web/app/src/components/ui/slider.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

* import is invalid because 'PropsWithChildren' from 'react' is restricted. `PropsWithChildren` set `children` as optional, explicitly define `children` field in your type

Check failure on line 1 in packages/web/app/src/components/ui/slider.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

Strings must use singlequote
import * as SliderPrimitive from "@radix-ui/react-slider"

Check failure on line 2 in packages/web/app/src/components/ui/slider.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

Strings must use singlequote
import { cn } from "@/lib/utils"

Check failure on line 3 in packages/web/app/src/components/ui/slider.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

Strings must use singlequote

const Slider = React.forwardRef<
React.ElementRef<typeof SliderPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
>(({ className, ...props }, ref) => (
<SliderPrimitive.Root
ref={ref}
className={cn(
"relative flex w-full touch-none select-none items-center disabled:cursor-not-allowed",

Check failure on line 12 in packages/web/app/src/components/ui/slider.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

Strings must use singlequote
className
)}
{...props}
>
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-black dark:bg-white disabled:pointer-events-none">
<SliderPrimitive.Range className="absolute h-full bg-black dark:bg-white disabled:pointer-events-none" />
</SliderPrimitive.Track>
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-black dark:border-white bg-black dark:bg-white ring-offset-orange-900 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed" />

Check failure on line 20 in packages/web/app/src/components/ui/slider.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

Classnames 'h-5, w-5' could be replaced by the 'size-5' shorthand!
</SliderPrimitive.Root>
))
Slider.displayName = SliderPrimitive.Root.displayName

export { Slider }
14 changes: 0 additions & 14 deletions packages/web/app/src/components/v2/slider.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { Subtitle, Title } from '@/components/ui/page';
import { QueryError } from '@/components/ui/query-error';
import { Card } from '@/components/v2/card';
import { Input } from '@/components/v2/input';
import { Slider } from '@/components/v2/slider';
import Stat from '@/components/v2/stat';
import { FragmentType, graphql, useFragment } from '@/gql';
import { BillingPlanType } from '@/gql/graphql';
import { OrganizationAccessScope, useOrganizationAccess } from '@/lib/access/organization';
import { CardElement, useElements, useStripe } from '@stripe/react-stripe-js';
import { Link } from '@tanstack/react-router';
import { Slider } from '@/components/ui/slider';

const ManageSubscriptionInner_OrganizationFragment = graphql(`
fragment ManageSubscriptionInner_OrganizationFragment on Organization {
Expand Down
62 changes: 62 additions & 0 deletions packages/web/app/src/stories/slider.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Meta, StoryObj } from '@storybook/react';
import React, { useEffect } from 'react';

Check failure on line 2 in packages/web/app/src/stories/slider.stories.tsx

View workflow job for this annotation

GitHub Actions / code-style / eslint-and-prettier

'React' is defined but never used. Allowed unused vars must match /^_/u
import { Slider } from '../components/ui/slider';


const meta: Meta<typeof Template> = {
title: 'Components/Slider',
component: Template,
argTypes: {
min: {
control: 'number',
defaultValue: 0,
},
max: {
control: 'number',
defaultValue: 100,
},
step: {
control: 'number',
defaultValue: 1,
},
disabled: {
control: 'boolean',
defaultValue: false,
},
},
args: {
min: 0,
max: 100,
step: 1,
}
};

export default meta;

type Story = StoryObj<typeof Template>

function Template({ min, max, step, disabled }: { min: number, max: number, step: number, disabled: boolean }) {
useEffect(() => {
console.log('min, max, or step changed');
}, [min, max, step, disabled]);

return (
<div className='w-1/2 mx-auto'>
<Slider
min={min}
max={max}
step={step}
disabled={disabled}
/>
</div>
);
}

export const Default: Story = {
args: {
min: 1,
step: 10,
max: 100,
disabled: true,
}
};
Loading