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 RadioButton #159

Merged
merged 1 commit into from
Jun 2, 2023
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
10 changes: 10 additions & 0 deletions src/components/RadioButton/RadioButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { RadioButton } from './RadioButton';

export default {
title: 'Components/Radio Button',
component: RadioButton,
};

export const _RadioButton = {
render: () => <RadioButton />,
};
13 changes: 13 additions & 0 deletions src/components/RadioButton/RadioButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import { RadioButton } from './RadioButton';

describe('Components | Buttons | Account Selector', () => {
test('it should render', () => {
render(<RadioButton />);

let radioButton = screen.getByTestId('radio-button');

expect(radioButton).toBeInTheDocument();
});
});
32 changes: 32 additions & 0 deletions src/components/RadioButton/RadioButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import React from 'react';
import { ComponentPropsWithoutRef } from 'react';

export type RadioButtonProps = ComponentPropsWithoutRef<'div'>;

export function RadioButton(props: RadioButtonProps) {
let { ...rest } = props;

return (
<div data-testid="radio-button">
<div className="inline-flex items-center">
<label className="relative flex cursor-pointer items-center rounded-full p-3">
<input
type="radio"
className={`peer relative h-5 w-5
cursor-pointer appearance-none rounded-full
border-2 border-gray-400 checked:border-green-500`}
{...rest}
/>
mazmassa marked this conversation as resolved.
Show resolved Hide resolved
<div
className={`pointer-events-none absolute top-2/4 left-2/4
-translate-y-2/4 -translate-x-2/4 bg-green-500
w-2.5 h-2.5 rounded-full opacity-0
transition-opacity peer-checked:opacity-100`}
></div>
</label>
</div>
</div>
);
}
1 change: 1 addition & 0 deletions src/components/RadioButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './RadioButton';
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './Icons';
export * from './Toggle';
export * from './Balance';
export * from './ThemeMode';
export * from './RadioButton';