-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refa <Input> and <Input.Field> components and support icons (#…
…2824) Co-authored-by: Sebastian Sebald <sebastian.sebald@reservix.de>
- Loading branch information
Showing
18 changed files
with
190 additions
and
159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@marigold/docs": patch | ||
"@marigold/components": minor | ||
--- | ||
|
||
chore: refa <Input> and <Input.Field> components and support icons |
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.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 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,55 @@ | ||
import React, { forwardRef } from 'react'; | ||
import { | ||
Box, | ||
ResponsiveStyleValue, | ||
ThemeExtension, | ||
useComponentStyles, | ||
} from '@marigold/system'; | ||
import { HtmlProps } from '@marigold/types'; | ||
import { Box, ThemeExtension, useComponentStyles } from '@marigold/system'; | ||
import React, { ReactNode } from 'react'; | ||
import { InputField } from './InputField'; | ||
|
||
// Theme Extension | ||
// --------------- | ||
export interface InputThemeExtension extends ThemeExtension<'Input'> {} | ||
|
||
// Props | ||
// --------------- | ||
export interface InputOwnProps extends Omit<HtmlProps<'input'>, 'size'> { | ||
size?: string; | ||
export interface InputProps extends Omit<HtmlProps<'div'>, 'size'> { | ||
children: ReactNode; | ||
space?: ResponsiveStyleValue<string>; | ||
variant?: string; | ||
size?: string; | ||
} | ||
|
||
export interface InputProps | ||
extends Omit<React.ComponentPropsWithRef<'input'>, 'size'>, | ||
InputOwnProps {} | ||
|
||
// Component | ||
// --------------- | ||
export const Input = forwardRef<HTMLInputElement, InputOwnProps>( | ||
({ variant, size, type = 'text', ...props }: InputOwnProps, ref) => { | ||
const styles = useComponentStyles('Input', { variant, size }); | ||
return <Box {...props} ref={ref} as="input" type={type} css={styles} />; | ||
} | ||
); | ||
export const Input = ({ | ||
space = 'xsmall', | ||
children, | ||
variant, | ||
size, | ||
...props | ||
}: InputProps) => { | ||
const [leading, input, trailing] = React.Children.toArray(children); | ||
|
||
const styles = useComponentStyles('Input', { variant, size }); | ||
|
||
return ( | ||
<Box | ||
__baseCSS={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
width: '100%', | ||
gap: space, | ||
}} | ||
css={styles} | ||
{...props} | ||
> | ||
{leading} | ||
{input} | ||
{trailing} | ||
</Box> | ||
); | ||
}; | ||
|
||
Input.Field = InputField; |
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,27 @@ | ||
import React, { forwardRef } from 'react'; | ||
import { HtmlProps } from '@marigold/types'; | ||
import { Box } from '@marigold/system'; | ||
|
||
// Props | ||
// --------------- | ||
export interface InputFieldOwnProps extends Omit<HtmlProps<'input'>, 'size'> {} | ||
|
||
export interface InputFieldProps | ||
extends Omit<React.ComponentPropsWithRef<'input'>, 'size'>, | ||
InputFieldOwnProps {} | ||
|
||
// Component | ||
// --------------- | ||
export const InputField = forwardRef<HTMLInputElement, InputFieldOwnProps>( | ||
({ type = 'text', ...props }: InputFieldOwnProps, ref) => { | ||
return ( | ||
<Box | ||
__baseCSS={{ border: 0, width: '100%', outline: 'none' }} | ||
{...props} | ||
ref={ref} | ||
as="input" | ||
type={type} | ||
/> | ||
); | ||
} | ||
); |
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 +1,2 @@ | ||
export * from './InputField'; | ||
export * from './Input'; |
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
Oops, something went wrong.