Skip to content

Commit 366e570

Browse files
committed
Merged heading-icon into heading component
1 parent aebedff commit 366e570

7 files changed

Lines changed: 44 additions & 145 deletions

File tree

src/atoms/typography/heading-icon.stories.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/atoms/typography/heading-icon.test.tsx

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/atoms/typography/heading-icon.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/atoms/typography/heading.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@import "../../assets/scss/6-components/_component-base";
2+
3+
/*------------------------------------*\
4+
ANCHORS
5+
\*------------------------------------*/
6+
7+
.c-heading {
8+
display: flex;
9+
align-items: center;
10+
11+
.c-icon {
12+
margin-right: .25em;
13+
width: 1em;
14+
height: 1em;
15+
}
16+
}

src/atoms/typography/heading.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { select } from "@storybook/addon-knobs";
44
import { HeadingPriority } from "../constants/heading-priority";
55
import { Heading } from "./heading";
66
import { CoreUtils } from "andculturecode-javascript-core";
7+
import { Icons } from "../constants/icons";
78

89
export default {
910
component: Heading,
@@ -17,6 +18,13 @@ export const headingKnobs = () => {
1718

1819
return (
1920
<Heading
21+
icon={
22+
select(
23+
"icon",
24+
Icons,
25+
Icons.Plus
26+
) as Icons
27+
}
2028
priority={
2129
select(
2230
"priority",

src/atoms/typography/heading.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import React, { PropsWithChildren } from "react";
22
import { HeadingPriority } from "../constants/heading-priority";
3+
import { IconSizes } from "../constants/icon-sizes";
4+
import { Icons } from "../constants/icons";
5+
import { Icon } from "../icons/icon";
6+
import "./heading.scss";
37

48
// -----------------------------------------------------------------------------------------
59
// #region Interfaces
610
// -----------------------------------------------------------------------------------------
711

812
export interface HeadingProps {
913
cssClassName?: string;
14+
icon?: Icons;
15+
iconSize?: IconSizes;
1016
id?: string;
1117
priority?: HeadingPriority;
1218
}
@@ -20,7 +26,7 @@ export interface HeadingProps {
2026
const Heading: React.FC<HeadingProps> = (
2127
props: PropsWithChildren<HeadingProps>
2228
) => {
23-
let cssClassNames: Array<any> = [];
29+
let cssClassNames: Array<any> = ["c-heading"];
2430

2531
if (props.cssClassName) {
2632
cssClassNames.push(props.cssClassName);
@@ -30,10 +36,22 @@ const Heading: React.FC<HeadingProps> = (
3036
className: cssClassNames.join(" "),
3137
};
3238

39+
const content = (
40+
<React.Fragment>
41+
{// if
42+
props.icon && (
43+
<Icon type={props.icon} />
44+
)}
45+
<span>
46+
{props.children}
47+
</span>
48+
</React.Fragment>
49+
)
50+
3351
return React.createElement(
3452
`h${props.priority ?? HeadingPriority.Two}`,
3553
componentProps,
36-
props.children
54+
content
3755
);
3856
};
3957

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export { TextInput } from "./atoms/forms/text-input";
1717

1818
// Typography
1919
export { Heading } from "./atoms/typography/heading";
20-
export { HeadingIcon } from "./atoms/typography/heading-icon";
2120
export { Paragraph } from "./atoms/typography/paragraph";
2221

2322
// #endregion Atoms

0 commit comments

Comments
 (0)