mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-24 10:00:52 -04:00
* Add TS configs and improve dir structure * Add TS configs and improve dir structure * Fix components exports from index * chore: prettier * Add tsconfig and then fix the linter warnings * Add @babel/preset-typescript * Fix eslint rule and update btn component to fix storybook * Fix TS and Jest configs Converted all remaining files to TS as well * Remove TS ignored rules and fixed some TS & jest stuff * Revert to old directory structure * Use absolute versions in package.json * enable ts strict to infer types Co-authored-by: Hamza Waleed <hamza.waleed@arbisoft.com>
35 lines
656 B
TypeScript
35 lines
656 B
TypeScript
import React from 'react';
|
|
import { ButtonProps } from './button.types';
|
|
|
|
import './button.css';
|
|
|
|
/**
|
|
* Primary UI component for user interaction
|
|
*/
|
|
export const Button: React.FC<ButtonProps> = ({
|
|
primary,
|
|
size = 'medium',
|
|
backgroundColor,
|
|
label,
|
|
...props
|
|
}: ButtonProps) => {
|
|
const mode = primary
|
|
? 'storybook-button--primary'
|
|
: 'storybook-button--secondary';
|
|
return (
|
|
<button
|
|
className={[
|
|
'storybook-button',
|
|
`storybook-button--${size}`,
|
|
mode,
|
|
'fcc-style'
|
|
].join(' ')}
|
|
style={{ backgroundColor }}
|
|
type='button'
|
|
{...props}
|
|
>
|
|
{label}
|
|
</button>
|
|
);
|
|
};
|