Skip to content

Commit

Permalink
feat(InlineEditor): align default background with DS 5.7 (#3757)
Browse files Browse the repository at this point in the history
  • Loading branch information
MEsteves22 committed Oct 20, 2023
1 parent a9944a8 commit 4cc2796
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/components/InlineEditor/InlineEditor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ export const Main: StoryObj<HvInlineEditorProps> = {
},
};

export const Disabled: StoryObj<HvInlineEditorProps> = {
render: () => {
return (
<div style={{ width: 300 }}>
<HvInlineEditor disabled />
</div>
);
},
};

export const LargeVariants = () => {
const [value, setValue] = useState(
"Very very very long text that is likely to be truncated"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export const { staticClasses, useClasses } = createClasses("HvInlineEditor", {
justifyContent: "flex-start",
alignItems: "center",

backgroundColor: "transparent",
backgroundColor: theme.colors.atmo1,
border: `1px solid transparent`,

"&:hover, &:focus": {
border: `1px solid ${theme.colors.primary}`,
backgroundColor: "transparent",
backgroundColor: theme.colors.atmo1,

"& $icon": {
visibility: "visible",
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/components/InlineEditor/InlineEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface HvInlineEditorProps
buttonProps?: HvButtonProps;
/** Props passed to the HvTypography text component */
typographyProps?: HvTypographyProps;
/** Whether the editor is disabled or not. */
disabled?: boolean;
/** A Jss Object used to override or extend the styles applied to the empty state component. */
classes?: HvInlineEditorClasses;
}
Expand All @@ -66,6 +68,7 @@ export const HvInlineEditor = (props: HvInlineEditorProps) => {
onKeyDown,
buttonProps,
typographyProps,
disabled,
...others
} = useDefaultProps("HvInlineEditor", props);

Expand Down Expand Up @@ -115,7 +118,7 @@ export const HvInlineEditor = (props: HvInlineEditorProps) => {

return (
<div className={cx(classes.root, className)}>
{editMode ? (
{editMode && !disabled ? (
<InputComponent
inputRef={inputRef}
classes={{
Expand Down Expand Up @@ -143,13 +146,16 @@ export const HvInlineEditor = (props: HvInlineEditorProps) => {
<Edit
color="secondary_60"
role="none"
className={cx(classes.icon, { [classes.iconVisible]: showIcon })}
className={cx(classes.icon, {
[classes.iconVisible]: showIcon,
})}
/>
}
className={cx(classes.button, {
[classes.largeText]: parseInt(lineHeight as string, 10) >= 28,
})}
onClick={handleClick}
disabled={disabled}
{...buttonProps}
>
<HvTypography
Expand Down
2 changes: 2 additions & 0 deletions packages/styles/src/themes/ds3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,10 @@ const ds3 = makeTheme((theme) => ({
classes: {
button: {
border: "none",
backgroundColor: "transparent",
"&:hover": {
border: "none",
backgroundColor: "transparent",
},
"&:focus": {
border: "none",
Expand Down

0 comments on commit 4cc2796

Please sign in to comment.