-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported the `input` component into tailwind. Split into two components for numeric and text input. Also removed unnecessary scss files and moved `rucio.d.ts` to `src/component-library/components.d.ts` to reflect that this file only provides the interfaces for the components.
- Loading branch information
Showing
15 changed files
with
238 additions
and
7,541 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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 was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/component-library/components/Box/components/BoxFooter.tsx
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,35 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react' | ||
import { StoryFn, Meta } from '@storybook/react' | ||
|
||
import { Input } from './Input' | ||
import { NumberInput } from './NumberInput' | ||
|
||
export default { | ||
title: 'Components/Input', | ||
component: Input, | ||
} as ComponentMeta<typeof Input> | ||
} as Meta<typeof Input> | ||
|
||
const Template: ComponentStory<typeof Input> = args => <Input {...args} /> | ||
const TemplateText: StoryFn<typeof Input> = args => <Input {...args} /> | ||
|
||
export const TextInput = Template.bind({}) | ||
export const TextInput = TemplateText.bind({}) | ||
TextInput.args = { | ||
size: 'medium', | ||
kind: 'primary', | ||
disabled: false, | ||
focusByDefault: false, | ||
inline: false, | ||
label: 'TextInput', | ||
password: false, | ||
placeholder: 'Placeholder String', | ||
show: 'standard' | ||
} | ||
|
||
export const NumberInput = Template.bind({}) | ||
NumberInput.args = { | ||
type: 'number', | ||
show: 'rounded', | ||
kind: 'primary', | ||
label: 'NumberInput', | ||
min: 0, | ||
max: 5, | ||
} | ||
// export const NumericInput = TemplateNumber.bind({}) | ||
// NumericInput.args = { | ||
// disabled: false, | ||
// focusByDefault: false, | ||
// inline: false, | ||
// label: 'TextInput', | ||
// max: 100, | ||
// min: 0, | ||
// password: false, | ||
// placeholder: 'Placeholder String', | ||
// show: 'standard' | ||
// } |
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 |
---|---|---|
@@ -1,35 +1,62 @@ | ||
import './input.scss' | ||
|
||
export const Input = ({ | ||
type = 'text', | ||
label, | ||
name = 'sample', | ||
placeholder = 'Sample placeholder', | ||
size = 'medium', | ||
kind = 'normal', | ||
show, | ||
value, | ||
disabled = false, | ||
focusByDefault = false, | ||
min, | ||
max, | ||
inline = false, | ||
label = "", | ||
onChange, | ||
width, | ||
}: InputProps) => { | ||
password = false, | ||
placeholder = "", | ||
show, | ||
}: TextInputProps) => { | ||
var divClasses: string[] = ["w-full"] | ||
var labelClasses: string[] = [] | ||
var inputClasses: string[] = ["border", "rounded"] | ||
|
||
// Handle inline or block | ||
if (!inline) { | ||
divClasses.push("block") | ||
labelClasses.push("block") | ||
inputClasses.push("block", "w-full", "p-2", "-mt-4") | ||
} | ||
else { | ||
divClasses.push("grid", "grid-cols-3", "gap-2", "p-1") | ||
labelClasses.push("col-span-1", "text-right", "self-center") | ||
inputClasses.push("col-span-2", "p-1") | ||
} | ||
|
||
// Handle show (only if not disabled) | ||
if(!disabled) { | ||
switch(show) { | ||
case "error": | ||
inputClasses.push("border-red-500", "bg-red-100") | ||
break | ||
case "success": | ||
inputClasses.push("border-green-500", "bg-green-100") | ||
break | ||
default: | ||
inputClasses.push("border-gray-300", "bg-gray-50") | ||
break | ||
} | ||
} | ||
|
||
return ( | ||
<label> | ||
{label} | ||
<div | ||
className={divClasses.join(" ")} | ||
> | ||
<label | ||
className={labelClasses.join(" ")} | ||
> | ||
{label} | ||
</label> | ||
<input | ||
type={type} | ||
name={name} | ||
placeholder={placeholder} | ||
className={`rucio-input ${kind} ${size} ${show}`} | ||
className={inputClasses.join(" ")} | ||
onChange={onChange} | ||
value={value} | ||
placeholder={placeholder} | ||
autoFocus={focusByDefault} | ||
min={min} | ||
max={max} | ||
style={{ width }} | ||
></input> | ||
</label> | ||
disabled={disabled} | ||
type={password ? "password" : "text"} | ||
> | ||
</input> | ||
</div> | ||
) | ||
} |
22 changes: 22 additions & 0 deletions
22
src/component-library/components/Input/NumberInput.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,22 @@ | ||
import { StoryFn, Meta } from '@storybook/react' | ||
|
||
import { NumberInput } from './NumberInput' | ||
|
||
export default { | ||
title: 'Components/Input', | ||
component: NumberInput, | ||
} as Meta<typeof NumberInput> | ||
|
||
const Template: StoryFn<typeof NumberInput> = args => <NumberInput {...args} /> | ||
|
||
export const NumericInput = Template.bind({}) | ||
NumericInput.args = { | ||
disabled: false, | ||
focusByDefault: false, | ||
inline: false, | ||
label: 'NumberInput', | ||
max: 100, | ||
min: 0, | ||
placeholder: 'Placeholder String', | ||
show: 'standard' | ||
} |
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,65 @@ | ||
export const NumberInput = ({ | ||
disabled = false, | ||
focusByDefault = false, | ||
inline = false, | ||
label = "", | ||
max, | ||
min, | ||
onChange, | ||
placeholder = "", | ||
show, | ||
}: NumberInputProps) => { | ||
var divClasses: string[] = ["w-full"] | ||
var labelClasses: string[] = [] | ||
var inputClasses: string[] = ["border", "rounded"] | ||
|
||
// Handle inline or block | ||
if (!inline) { | ||
divClasses.push("block") | ||
labelClasses.push("block") | ||
inputClasses.push("block", "w-full", "p-2", "-mt-4") | ||
} | ||
else { | ||
divClasses.push("grid", "grid-cols-3", "gap-2", "p-1") | ||
labelClasses.push("col-span-1", "text-right", "self-center") | ||
inputClasses.push("col-span-2", "p-1") | ||
} | ||
|
||
// Handle show (only if not disabled) | ||
if(!disabled) { | ||
switch(show) { | ||
case "error": | ||
inputClasses.push("border-red-500", "bg-red-100") | ||
break | ||
case "success": | ||
inputClasses.push("border-green-500", "bg-green-100") | ||
break | ||
default: | ||
inputClasses.push("border-gray-300", "bg-gray-50") | ||
break | ||
} | ||
} | ||
|
||
return ( | ||
<div | ||
className={divClasses.join(" ")} | ||
> | ||
<label | ||
className={labelClasses.join(" ")} | ||
> | ||
{label} | ||
</label> | ||
<input | ||
className={inputClasses.join(" ")} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
autoFocus={focusByDefault} | ||
disabled={disabled} | ||
max={max ? max.toString() : ""} | ||
min={min ? min.toString() : ""} | ||
type="number" | ||
> | ||
</input> | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.