-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
167 additions
and
26 deletions.
There are no files selected for viewing
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 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,59 @@ | ||
import React, { useState } from '@rbxts/react'; | ||
|
||
import { Box } from 'components/Box'; | ||
import { useTheme } from 'components/ThemeProvider'; | ||
import { mergeFunctions } from 'helpers'; | ||
|
||
import type { PropsWithChildren } from '@rbxts/react'; | ||
import type { BoxProps } from 'components/Box'; | ||
|
||
export interface InputProps extends BoxProps<'textbox'> { | ||
Disabled?: boolean; | ||
} | ||
|
||
export function Input(componentProps: PropsWithChildren<InputProps>) { | ||
const props = { ...componentProps }; | ||
|
||
const disabled = props.Disabled ?? false; | ||
props.Disabled = undefined; | ||
|
||
const theme = useTheme(); | ||
const [focused, setFocused] = useState<boolean>(false); | ||
|
||
return ( | ||
<Box | ||
AutomaticSize="Y" | ||
BackgroundColor3={theme.overlay} | ||
BorderColor3={focused && !disabled ? theme.accent : theme.borders} | ||
BorderRadius={8} | ||
BorderThickness={2} | ||
ClearTextOnFocus={false} | ||
ClipsDescendants | ||
Component="textbox" | ||
PaddingX={2} | ||
PaddingY={1.5} | ||
PlaceholderColor3={theme.primary60} | ||
PlaceholderText="Placeholder" | ||
Size={UDim2.fromScale(1, 0)} | ||
Text="" | ||
TextColor3={disabled ? theme.primary60 : theme.primary} | ||
TextEditable={!disabled} | ||
TextSize={12} | ||
TextTransparency={disabled ? 0.25 : 0} | ||
TextXAlignment={Enum.TextXAlignment.Left} | ||
{...props} | ||
Event={{ | ||
...props.Event, | ||
Focused: mergeFunctions(() => setFocused(true), props.Event?.Focused), | ||
FocusLost: mergeFunctions( | ||
() => setFocused(false), | ||
props.Event?.FocusLost, | ||
), | ||
}} | ||
StrokeProps={{ | ||
Transparency: disabled ? 0.5 : 0, | ||
...props.StrokeProps, | ||
}} | ||
/> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from '@rbxts/react'; | ||
import ReactRoblox from '@rbxts/react-roblox'; | ||
|
||
import Center from './components/Center'; | ||
import { Box } from 'components/Box'; | ||
import { Input } from 'components/Input'; | ||
import { Sheet } from 'components/Sheet'; | ||
import { ThemeProvider } from 'components/ThemeProvider'; | ||
import { darkTheme } from 'themes'; | ||
|
||
import type { FunctionStory } from '@rbxts/ui-labs'; | ||
|
||
const story: FunctionStory = (target) => { | ||
const element = ( | ||
<Center> | ||
<Box Gap={2}> | ||
<Sheet | ||
AutomaticSize="Y" | ||
Gap={2} | ||
Padding={4} | ||
Size={new UDim2(0, 300, 0, 0)} | ||
> | ||
<Input /> | ||
|
||
<Input Disabled PlaceholderText="Disabled" /> | ||
</Sheet> | ||
|
||
<ThemeProvider theme={darkTheme}> | ||
<Sheet | ||
AutomaticSize="Y" | ||
Gap={2} | ||
Padding={4} | ||
Size={new UDim2(0, 300, 0, 0)} | ||
> | ||
<Input /> | ||
|
||
<Input Disabled PlaceholderText="Disabled" /> | ||
</Sheet> | ||
</ThemeProvider> | ||
</Box> | ||
</Center> | ||
); | ||
|
||
const root = ReactRoblox.createRoot(target); | ||
root.render(element); | ||
|
||
return () => { | ||
root.unmount(); | ||
}; | ||
}; | ||
|
||
export = story; |
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