-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: nina992 <[email protected]>
- Loading branch information
Showing
4 changed files
with
153 additions
and
11 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
web/src/beta/components/fields/NumberField/index.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import NumberField, { Props } from "."; | ||
|
||
const meta: Meta<Props> = { | ||
component: NumberField, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof NumberField>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
value: 42, | ||
inputDescription: "Value", | ||
suffix: "px", | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
value: 15, | ||
inputDescription: "Disabled", | ||
suffix: "px", | ||
disabled: true, | ||
}, | ||
}; | ||
|
||
export const Range: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
value: 50, | ||
inputDescription: "Range", | ||
suffix: "px", | ||
min: 4, | ||
max: 100, | ||
}, | ||
}; | ||
|
||
export const NoValue: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
inputDescription: "No Value", | ||
suffix: "px", | ||
}, | ||
}; | ||
|
||
export const WithMinValue: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
value: 5, | ||
inputDescription: "With Min Value", | ||
suffix: "px", | ||
min: 0, | ||
}, | ||
}; | ||
|
||
export const WithMaxValue: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
value: 95, | ||
inputDescription: "With Max Value", | ||
suffix: "px", | ||
max: 100, | ||
}, | ||
}; | ||
|
||
export const Editable: Story = { | ||
args: { | ||
name: "Number Field", | ||
description: "The Number field", | ||
value: 25, | ||
inputDescription: "Editable", | ||
suffix: "px", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Property from ".."; | ||
import NumberInput from "../common/NumberInput"; | ||
|
||
export type Props = { | ||
name?: string; | ||
description?: string; | ||
suffix?: string; | ||
min?: number; | ||
max?: number; | ||
disabled?: boolean; | ||
inputDescription?: string; | ||
value?: number; | ||
onChange?: (value?: number | undefined) => void; | ||
}; | ||
|
||
const NumberField: React.FC<Props> = ({ | ||
name, | ||
description, | ||
value, | ||
min, | ||
max, | ||
suffix, | ||
inputDescription, | ||
disabled, | ||
onChange, | ||
}) => { | ||
return ( | ||
<Property name={name} description={description}> | ||
<NumberInput | ||
value={value} | ||
onChange={onChange} | ||
min={min} | ||
max={max} | ||
suffix={suffix} | ||
disabled={disabled} | ||
inputDescription={inputDescription} | ||
/> | ||
</Property> | ||
); | ||
}; | ||
|
||
export default NumberField; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters