Skip to content

Commit 4b9297f

Browse files
authored
Merge pull request #279 from puppetlabs/features/add-container-element-sidebar-item
Add `containerElement` prop to Sidebar.Item
2 parents 9a8fc63 + 37d02f0 commit 4b9297f

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# 5.22.0 (2020-08-12)
1+
# Next
22

33
- [Copy] Add Copy component (by [@nkanderson](https://github.com/nkanderson) in [#270](https://github.com/puppetlabs/design-system/pull/270))
4+
- [Sidebar] Add `containerElement` prop to Sidebar.Item (by [@vine77](https://github.com/vine77) in [#279](https://github.com/puppetlabs/design-system/pull/279))
45

56
# 5.21.1 (2020-06-30)
67

packages/design-system-website/styleguideComponents/ComponentsListRenderer.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function ComponentsListRenderer({ items: allItems, ...rest }) {
3131

3232
return (
3333
<Sidebar.Item
34+
containerElement="div"
3435
active={isItemSelected}
3536
href={href}
3637
key={href}

packages/design-system-website/styleguideComponents/TableOfContentsRenderer.scss

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
@import '~@puppet/sass-variables/index';
22

3-
.rc-sidebar-navigation {
4-
margin-top: 0;
5-
padding-top: 0;
6-
}
7-
83
.pds-filter {
9-
margin: 4 * $puppet-common-spacing-base;
4+
margin-bottom: 4 * $puppet-common-spacing-base;
105

116
.rc-input {
127
background-color: $puppet-n950;

packages/react-components/source/react/library/sidebar/Sidebar.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ import Badge from '../badge';
2929
href="/"
3030
/>
3131
<Sidebar.Navigation>
32-
<Sidebar.Section>
33-
<Sidebar.Item onClick={() => {}} title="Home" icon="home" active />
34-
</Sidebar.Section>
32+
<Sidebar.Item
33+
onClick={() => {}}
34+
title="Home"
35+
icon="home"
36+
active
37+
containerElement="div"
38+
/>
3539
<Sidebar.Section label="reports">
3640
<Sidebar.Item onClick={() => {}} title="Code" icon="code" />
3741
<Sidebar.Item onClick={() => {}} title="Build" icon="build" count={5} />
@@ -82,9 +86,13 @@ Add the `minimized` boolean prop to Sidebar to render a narrow version with icon
8286
ariaLabel="Return to the home page"
8387
/>
8488
<Sidebar.Navigation>
85-
<Sidebar.Section>
86-
<Sidebar.Item onClick={() => {}} title="Home" icon="home" active />
87-
</Sidebar.Section>
89+
<Sidebar.Item
90+
onClick={() => {}}
91+
title="Home"
92+
icon="home"
93+
active
94+
containerElement="div"
95+
/>
8896
<Sidebar.Section label="reports">
8997
<Sidebar.Item onClick={() => {}} title="Code" icon="code" />
9098
<Sidebar.Item onClick={() => {}} title="Build" icon="build" />

packages/react-components/source/react/library/sidebar/SidebarItem.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import TooltipHoverArea from '../tooltips/TooltipHoverArea';
77

88
const propTypes = {
99
as: PropTypes.elementType,
10+
containerElement: PropTypes.elementType,
1011
title: PropTypes.string.isRequired,
1112
icon: PropTypes.string,
1213
className: PropTypes.string,
@@ -18,6 +19,7 @@ const propTypes = {
1819

1920
const defaultProps = {
2021
as: 'a',
22+
containerElement: 'li',
2123
icon: '',
2224
className: '',
2325
minimized: false,
@@ -36,6 +38,7 @@ const SidebarItem = props => {
3638
count,
3739
badge: badgeProp,
3840
as: Component,
41+
containerElement: ContainerComponent,
3942
...rest
4043
} = props;
4144

@@ -96,7 +99,7 @@ const SidebarItem = props => {
9699
</Component>
97100
);
98101

99-
return <li className={classNames}>{link}</li>;
102+
return <ContainerComponent className={classNames}>{link}</ContainerComponent>;
100103
};
101104

102105
SidebarItem.propTypes = propTypes;

packages/react-components/source/scss/library/components/_sidebar.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $puppet-sidebar-item-color-active: $puppet-brand-primary !default;
2222
$puppet-sidebar-item-font-size: 16px !default;
2323
$puppet-sidebar-item-font-weight: $puppet-type-weight-normal !default;
2424
$puppet-sidebar-item-line-height: 40px !default;
25-
$puppet-sidebar-item-margin: 2px 16px !default;
25+
$puppet-sidebar-item-margin: 2px 0 !default;
2626
$puppet-sidebar-item-padding: 0 12px !default;
2727
$puppet-sidebar-item-title-padding: 4px 0 !default;
2828

@@ -42,7 +42,7 @@ $puppet-sidebar-label-font-size: 11px !default;
4242
$puppet-sidebar-label-line-height: $puppet-common-spacing-base * 2 !default;
4343
$puppet-sidebar-label-margin: $puppet-common-spacing-base * 6 0
4444
$puppet-common-spacing-base * 2 !default;
45-
$puppet-sidebar-label-padding: 0 $puppet-common-spacing-base * 6 0 !default;
45+
$puppet-sidebar-label-padding: 0 $puppet-common-spacing-base * 2 0 !default;
4646
$puppet-sidebar-label-text-transform: uppercase !default;
4747

4848
$puppet-sidebar-item-accordion-font-size: 14px !default;
@@ -97,7 +97,7 @@ $puppet-sidebar-footer-meta-icon: 32px;
9797
flex: 1;
9898
height: inherit;
9999
overflow: auto;
100-
padding: 16px 0;
100+
padding: 16px;
101101
}
102102

103103
// Sidebar section & items

0 commit comments

Comments
 (0)