Skip to content

Commit 9a4df96

Browse files
authored
Merge pull request #1871 from dxc-technology/jialecl/actionsCell-icon
Icon implemented in the actions cell
2 parents adc807a + 79d75b6 commit 9a4df96

File tree

8 files changed

+14
-40
lines changed

8 files changed

+14
-40
lines changed

lib/src/action-icon/ActionIcon.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ export const Chromatic = () => (
1919
<>
2020
<Title title="Default" theme="light" level={2} />
2121
<ExampleContainer>
22-
<DxcActionIcon icon={"https://www.freepnglogos.com/uploads/facebook-logo-design-1.png"} title="Favourite" />
22+
<DxcActionIcon icon="favorite" title="Favourite" />
2323
</ExampleContainer>
2424
<Title title="Disabled" theme="light" level={2} />
2525
<ExampleContainer>
26-
<DxcActionIcon icon={iconSVG} title="Favourite" disabled />
26+
<DxcActionIcon icon="favorite" title="Favourite" disabled />
2727
</ExampleContainer>
2828
<Title title="Hover" theme="light" level={2} />
2929
<ExampleContainer pseudoState="pseudo-hover">
30-
<DxcActionIcon icon={iconSVG} title="Favourite" />
30+
<DxcActionIcon icon="filled_favorite" title="Favourite" />
3131
</ExampleContainer>
3232
<Title title="Focus" theme="light" level={2} />
3333
<ExampleContainer pseudoState="pseudo-focus">

lib/src/action-icon/ActionIcon.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import ActionIconPropsTypes, { RefType } from "./types";
33
import styled from "styled-components";
44
import CoreTokens from "../common/coreTokens";
5+
import DxcIcon from "../icon/Icon";
56

67
const DxcActionIcon = React.forwardRef<RefType, ActionIconPropsTypes>(
78
({ disabled = false, title, icon, onClick, tabIndex }, ref): JSX.Element => {
@@ -18,7 +19,7 @@ const DxcActionIcon = React.forwardRef<RefType, ActionIconPropsTypes>(
1819
type="button"
1920
ref={ref}
2021
>
21-
{typeof icon === "string" ? <img src={icon} /> : icon}
22+
{typeof icon === "string" ? <DxcIcon icon={icon} /> : icon}
2223
</ActionIcon>
2324
);
2425
}
@@ -33,6 +34,7 @@ const ActionIcon = styled.button`
3334
border-radius: 2px;
3435
width: 24px;
3536
height: 24px;
37+
font-size: 16px;
3638
padding: 0px;
3739
${(props) => (props.disabled ? `cursor: not-allowed;` : `cursor: pointer;`)}
3840
@@ -65,7 +67,7 @@ const ActionIcon = styled.button`
6567
}
6668
`}
6769
68-
img, svg {
70+
svg {
6971
width: 16px;
7072
height: 16px;
7173
}

lib/src/action-icon/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Props = {
1010
*/
1111
title: string;
1212
/**
13-
* Element or path used as the icon that will be placed next to the label.
13+
* Material Symbol name or SVG element as the icon that will be placed next to the label.
1414
*/
1515
icon: string | SVG;
1616
/**

lib/src/resultset-table/ResultsetTable.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const actions = [
6262
],
6363
},
6464
{
65-
icon: "https://www.freepnglogos.com/uploads/facebook-logo-design-1.png",
65+
icon: "filled_edit",
6666
title: "icon",
6767
onClick: () => {},
6868
},

lib/src/table/Table.stories.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ const advancedTheme = {
2828
},
2929
};
3030

31-
const icon1 = (
32-
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
33-
<path d="M0 0h24v24H0V0z" fill="none" />
34-
<path d="M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z" />
35-
</svg>
36-
);
37-
3831
const actions = [
3932
{
4033
title: "icon",
@@ -98,12 +91,12 @@ const actions = [
9891
],
9992
},
10093
{
101-
icon: icon1,
94+
icon: "filled_edit",
10295
title: "icon",
10396
onClick: () => {},
10497
},
10598
{
106-
icon: icon1,
99+
icon: "filled_delete",
107100
title: "icon",
108101
onClick: () => {},
109102
disabled: true,

lib/src/table/Table.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import DxcFlex from "../flex/Flex";
1111
import { HalstackProvider } from "../HalstackContext";
1212
import DxcActionIcon from "../action-icon/ActionIcon";
1313

14-
const moreVertIcon = (
15-
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24" fill="currentColor">
16-
<path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z" />
17-
</svg>
18-
);
19-
2014
const overwriteTheme = (theme: DeepPartial<AdvancedTheme>) => {
2115
const newTheme = DropdownTheme;
2216
newTheme.dropdown.buttonBackgroundColor = theme.table.actionBackgroundColor;
@@ -55,7 +49,7 @@ export const DxcActionsCell = ({ actions }: ActionCellsPropsType): JSX.Element =
5549
options={actionDropdown.options}
5650
onSelectOption={actionDropdown.onClick}
5751
disabled={actionDropdown.disabled}
58-
icon={moreVertIcon}
52+
icon="more_vert"
5953
tabIndex={actionDropdown.tabIndex}
6054
caretHidden
6155
></DxcDropdown>

lib/src/table/types.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Option } from "../dropdown/types";
12
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
23
type Margin = {
34
top?: Space;
@@ -7,22 +8,6 @@ type Margin = {
78
};
89

910
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10-
type Option = {
11-
/**
12-
* Option display value.
13-
*/
14-
label?: string;
15-
/**
16-
* Element or path used as the icon that will be placed next to the
17-
* option label.
18-
*/
19-
icon?: string | SVG;
20-
/**
21-
* Option inner value.
22-
*/
23-
value: string;
24-
};
25-
2611
export type DeepPartial<T> = {
2712
[P in keyof T]?: Partial<T[P]>;
2813
};

lib/src/text-input/TextInput.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const actionLargeIconSVG = {
3535

3636
const actionLargeIconURL = {
3737
onClick: () => {},
38-
icon: "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png",
38+
icon: "search",
3939
};
4040

4141
const country = ["Afghanistan"];

0 commit comments

Comments
 (0)