Skip to content

Commit

Permalink
FieldLabel style changes for the recolouring theme (#2756)
Browse files Browse the repository at this point in the history
* chore: separate infoButton based on themes

* chore: changeset

* chore: add secondary-icon-button dependency
  • Loading branch information
chloe0592 authored Mar 21, 2024
1 parent 5606039 commit bfc3902
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-emus-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/field-label': patch
---

Separate which `InfoButton` is shown in the `FieldLabel` component based on the theme.
1 change: 1 addition & 0 deletions packages/components/field-label/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@commercetools-uikit/icon-button": "18.5.0",
"@commercetools-uikit/icons": "18.5.0",
"@commercetools-uikit/label": "18.5.0",
"@commercetools-uikit/secondary-icon-button": "18.5.0",
"@commercetools-uikit/spacings-inline": "18.5.0",
"@commercetools-uikit/spacings-stack": "18.5.0",
"@commercetools-uikit/text": "18.5.0",
Expand Down
31 changes: 21 additions & 10 deletions packages/components/field-label/src/field-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import { warning } from '@commercetools-uikit/utils';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import IconButton from '@commercetools-uikit/icon-button';
import { InformationIcon } from '@commercetools-uikit/icons';
import SecondaryIconButton from '@commercetools-uikit/secondary-icon-button';
import { InformationIcon, InfoIcon } from '@commercetools-uikit/icons';
import Text from '@commercetools-uikit/text';
import Constraints from '@commercetools-uikit/constraints';
import Inline from '@commercetools-uikit/spacings-inline';
import Label from '@commercetools-uikit/label';
import { designTokens } from '@commercetools-uikit/design-system';
import { designTokens, useTheme } from '@commercetools-uikit/design-system';

export type TFieldLabelProps = {
/**
Expand Down Expand Up @@ -104,6 +105,8 @@ const LabelRowWrapper = styled.div`
`;

const FieldLabel = (props: TFieldLabelProps) => {
const { themedValue } = useTheme();

if (props.hintIcon) {
warning(
props.hintIcon.props.size === undefined,
Expand All @@ -129,14 +132,22 @@ const FieldLabel = (props: TFieldLabelProps) => {
{props.title}
</Label>
</Text.Wrap>
{props.onInfoButtonClick && (
<IconButton
label="More Info"
icon={<InformationIcon />}
size="small"
onClick={props.onInfoButtonClick}
/>
)}
{props.onInfoButtonClick &&
themedValue(
<IconButton
label="More Info"
icon={<InformationIcon />}
size="small"
onClick={props.onInfoButtonClick}
/>,
<SecondaryIconButton
label="More Info"
icon={<InfoIcon />}
size="medium"
color="info"
onClick={props.onInfoButtonClick}
/>
)}
</Inline>

{props.hint && (
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,7 @@ __metadata:
"@commercetools-uikit/icon-button": 18.5.0
"@commercetools-uikit/icons": 18.5.0
"@commercetools-uikit/label": 18.5.0
"@commercetools-uikit/secondary-icon-button": 18.5.0
"@commercetools-uikit/spacings-inline": 18.5.0
"@commercetools-uikit/spacings-stack": 18.5.0
"@commercetools-uikit/text": 18.5.0
Expand Down

0 comments on commit bfc3902

Please sign in to comment.