Skip to content

Commit

Permalink
Merge pull request #207 from brainstormforce/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vrundakansara authored Dec 13, 2024
2 parents 66dab5e + c64cfb5 commit d533216
Show file tree
Hide file tree
Showing 10 changed files with 743 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import type { Preview } from '@storybook/react';

import '../src/tailwind.css';
/** @type { import('@storybook/react').Preview } */
import '../dist/style.css';

const preview: Preview = {
parameters: {
controls: {
Expand All @@ -20,7 +20,7 @@ const preview: Preview = {
},
decorators: [
(Story) => (
<div style={{ fontFamily: 'Figtree, sans-serif' }}>
<div className="[&_*]:[font-family:Figtree,sans-serif] [&_*]:box-border">
<Story />
</div>
),
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version x.x.x - x x, x
- Fixed - Asterisk missing on required input label.

Version 1.2.2 - 4th December, 2024
- Improvement - Removed margin and added new props to the Line Chart component for customizability.

Expand Down
4 changes: 2 additions & 2 deletions src/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ export const CheckboxComponent = (
return (
<div
className={ cn(
'inline-flex items-center gap-2',
'inline-flex items-center justify-center gap-2',
!! label && 'items-start',
disabled && 'cursor-not-allowed'
) }
>
<label
className={ cn(
'relative flex items-center rounded-full p-0.5',
'relative flex items-center justify-center rounded-full p-0.5',
! disabled && 'cursor-pointer'
) }
htmlFor={ checkboxId }
Expand Down
10 changes: 10 additions & 0 deletions src/components/input/input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ WithPrefixSuffix.args = {
suffix: '#',
defaultValue: '',
};

// Required Input with Label
export const Required = Template.bind( {} );
Required.args = {
type: 'text',
size: 'sm',
required: true,
label: 'Required Input',
defaultValue: 'Required Input',
};
12 changes: 9 additions & 3 deletions src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import React, {
forwardRef,
useRef,
type ReactNode,
LabelHTMLAttributes,
} from 'react';
import { nanoid } from 'nanoid';
import { cn } from '@/utilities/functions';
import { Upload, X } from 'lucide-react';
import Label from '../label';

export declare interface InputProps {
/** Unique identifier for the input element. */
Expand Down Expand Up @@ -52,6 +54,9 @@ export declare interface InputProps {

/** Placeholder text for the input field. */
placeholder?: string;

/** Indicates whether the input is required. */
required?: boolean;
}

export const InputComponent = (
Expand Down Expand Up @@ -245,12 +250,13 @@ export const InputComponent = (
return null;
}
return (
<label
className={ cn( labelClasses[ size ], 'text-field-label' ) }
<Label<LabelHTMLAttributes<HTMLLabelElement>>
className={ cn( labelClasses[ size ] ) }
htmlFor={ inputId }
{ ...( props?.required && { required: true } ) }
>
{ label }
</label>
</Label>
);
}, [ label, size, inputId ] );

Expand Down
9 changes: 6 additions & 3 deletions src/components/label/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface LabelProps {
}

const Label = forwardRef(
(
<T extends object>(
{
children = null,
tag: Tag = 'label',
Expand All @@ -26,7 +26,7 @@ const Label = forwardRef(
variant = 'neutral', // neutral, help, error, disabled
required = false,
...props
}: LabelProps,
}: LabelProps & T,
ref: React.Ref<HTMLElement>
) => {
// Base classes. - Mandatory classes.
Expand Down Expand Up @@ -78,4 +78,7 @@ const Label = forwardRef(
}
);

export default Label;
export default Label as <T extends object>(
props: LabelProps & T,
ref: React.Ref<HTMLElement>
) => React.ReactNode;
1 change: 1 addition & 0 deletions src/components/table/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Table } from './table';
Loading

0 comments on commit d533216

Please sign in to comment.