Skip to content

Commit

Permalink
feat(Inputs): Added readOnly to InputWrapper and make label `bold…
Browse files Browse the repository at this point in the history
…` in that case
  • Loading branch information
johan-fx committed Sep 19, 2024
1 parent 0ea27c4 commit e8bfbf4
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/components/src/form/ColorInput/ColorInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const ColorInput = forwardRef(
contentStyle={contentStyle}
headerClassName={headerClassName}
contentClassName={contentClassName}
readOnly={readOnly}
{...props}
>
{readOnly ? (
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const DatePicker = forwardRef(
headerStyle={headerStyle}
contentStyle={contentStyle}
style={style}
readOnly={readOnly}
>
{readOnly ? (
<Paragraph clean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ export const INPUT_LABEL_DEFAULT_PROPS = {
withDescriptionIcon: false,
required: false,
showEmptyLabel: false,
readOnly: false,
};
export const INPUT_LABEL_PROP_TYPES = {
label: PropTypes.string,
description: PropTypes.string,
withDescriptionIcon: PropTypes.bool,
required: PropTypes.bool,
showEmptyLabel: PropTypes.bool,
readOnly: PropTypes.bool,
};
3 changes: 2 additions & 1 deletion packages/components/src/form/InputLabel/InputLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const InputLabel = ({
withDescriptionIcon,
required,
showEmptyLabel,
readOnly,
...props
}) => {
const { classes } = InputLabelStyles({}, { name: 'InputLabel' });
const { classes } = InputLabelStyles({ readOnly }, { name: 'InputLabel' });

return (
<Box className={classes.container}>
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/form/InputLabel/InputLabel.styles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createStyles } from '@mantine/styles';

const InputLabelStyles = createStyles((theme) => {
const InputLabelStyles = createStyles((theme, { readOnly }) => {
const labelTheme = theme.other.label;

return {
Expand All @@ -12,6 +12,7 @@ const InputLabelStyles = createStyles((theme) => {
label: {
color: labelTheme.content.color.default,
...labelTheme.content.typo['02'],
fontWeight: readOnly ? 'bold' : 'normal',
},
required: {
marginLeft: labelTheme.spacing.gap.sm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const INPUT_WRAPPER_PROP_TYPES = {
contentStyle: PropTypes.any,
autoComplete: PropTypes.string,
showEmptyLabel: PropTypes.bool,
readOnly: PropTypes.bool,
};
export const INPUT_WRAPPER_DEFAULT_PROPS = {
label: '',
Expand All @@ -33,4 +34,5 @@ export const INPUT_WRAPPER_DEFAULT_PROPS = {
required: false,
autoComplete: 'off',
disabled: false,
readOnly: false,
};
2 changes: 2 additions & 0 deletions packages/components/src/form/InputWrapper/InputWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const InputWrapper = ({
style,
formValues,
showEmptyLabel,
readOnly,
...props
}) => {
const size = INPUT_WRAPPER_SIZES.includes(sizeProp) ? sizeProp : 'md';
Expand Down Expand Up @@ -60,6 +61,7 @@ const InputWrapper = ({
{...labelProps}
description={description}
withDescriptionIcon={withDescriptionIcon}
readOnly={readOnly}
/>
</Stack>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form/ListInput/ListInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const ListInput = ({
size={size}
error={error}
required={required}
readOnly={readonly}
>
<Box>
<SortableList
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form/NumberInput/NumberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const NumberInput = forwardRef(
contentStyle={contentStyle}
headerClassName={headerClassName}
contentClassName={contentClassName}
readOnly={readOnly}
>
{readOnly ? (
<Paragraph clean>{props.value || props.defaultValue || ''}</Paragraph>
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form/Select/Select.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ export const SELECT_PROP_TYPES = {
autoComplete: PropTypes.string,
readOnly: PropTypes.bool,
autoSelectOneOption: PropTypes.bool,
withinPortal: PropTypes.bool,
};
2 changes: 1 addition & 1 deletion packages/components/src/form/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const Select = forwardRef(
{...props}
></MultiSelect>
) : (
<InputWrapper {...props} uuid={uuid} size={size} error={error}>
<InputWrapper {...props} readOnly={readOnly} uuid={uuid} size={size} error={error}>
{readOnly ? (
<Paragraph clean>{dataValue}</Paragraph>
) : (
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/form/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const TextInput = forwardRef(
}, [variant]);

return (
<InputWrapper {...props} uuid={uuid} size={size} error={error}>
<InputWrapper {...props} readOnly={readOnly} uuid={uuid} size={size} error={error}>
{readOnly ? (
<Paragraph clean>{value || defaultValue || ''}</Paragraph>
) : (
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form/Textarea/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const Textarea = forwardRef(
return (
<InputWrapper
{...props}
readOnly={readOnly}
uuid={uuid}
size={size}
error={error}
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/form/TimeInput/TimeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const TimeInput = forwardRef(
contentStyle,
autoComplete,
style,
readOnly,
...props
},
ref,
Expand All @@ -52,6 +53,7 @@ const TimeInput = forwardRef(
headerStyle={headerStyle}
contentStyle={contentStyle}
style={style}
readOnly={readOnly}
>
<MantineTimeInput
{...props}
Expand Down
41 changes: 34 additions & 7 deletions packages/components/src/tokens.compiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ export default {
"y": 0,
"blur": 4,
"spread": 0,
"color": "#ffffff26",
"color": "#ffffff",
"type": "dropShadow"
},
"type": "boxShadow"
Expand Down Expand Up @@ -1625,8 +1625,17 @@ export default {
"type": "color"
},
"hover--reverse-transparent": {
"value": "#ffffff26",
"type": "color"
"value": "#ffffff",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "alpha",
"value": "0.15",
"space": "lch"
}
}
}
},
"down": {
"value": "#F1FFBD",
Expand Down Expand Up @@ -5286,12 +5295,30 @@ export default {
"color": {
"primary": {
"default": {
"value": "#4d535866",
"type": "color"
"value": "#4D5358",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "alpha",
"value": "0.4",
"space": "lch"
}
}
}
},
"hover": {
"value": "#4d5358b3",
"type": "color"
"value": "#4D5358",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "alpha",
"value": "0.7",
"space": "lch"
}
}
}
},
"down": {
"value": "#4D5358",
Expand Down

0 comments on commit e8bfbf4

Please sign in to comment.