Skip to content

Commit a3e9eb9

Browse files
author
Ayesha Mazumdar
authored
fix(margin): Update docs to include "none" option (#3361)
1 parent 35d90ba commit a3e9eb9

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

ui/utilities/margin/docs.mdx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ import Example from '../../../shared/components/Example';
33

44
<div className="lead">Adjust whitespace by applying horizontal and vertical margin helpers</div>
55

6-
The base unit of all our spacing metrics is **4**.
6+
The base unit of all of our spacing metrics is **4**.
77

88
**Before using**
9+
910
- Most components already come with spacing included. These utility classes are for added convenience in laying out components.
10-
- Classes prefixed by `.slds-m-` are used for adding **margins**. Classes prefixed in `.slds-p-` are used for adding **padding**
11+
- Classes prefixed by `slds-m-` are used for adding **margins**. Classes prefixed in `slds-p-` are used for adding [padding](/components/utilities/padding)
1112
- The directions available for the spacing classes are `top`, `right`, `bottom`, and `left`.
1213
- You can use the `vertical` shortcut for both `top` and `bottom`, `horizontal` for both `right` and `left`, and `around` for all sides.
1314
- Use the `_xxx-small` through `_xx-large` scale to choose the size needed.
14-
- Where **vertical centering** is required, check out our [/components/utilities/media-objects/#center](centered media object) instead of applying extra `margin` or `padding`.
15+
- You can also use `none` as the size on any of the directions to enforce zero margin.
16+
- Where **vertical centering** is required, check out our [centered media object](/components/utilities/media-objects/#center) instead of applying extra `margin` or `padding`.
1517

1618
## Location - Top
19+
1720
<Example title="top margins">
1821
<div>
22+
<Margin size="none" position="top" />
1923
<Margin size="xxx-small" position="top" />
2024
<Margin size="xx-small" position="top" />
2125
<Margin size="x-small" position="top" />
@@ -28,8 +32,10 @@ The base unit of all our spacing metrics is **4**.
2832
</Example>
2933

3034
## Location - Left
35+
3136
<Example title="left margins">
3237
<div>
38+
<Margin size="none" position="left" />
3339
<Margin size="xxx-small" position="left" />
3440
<Margin size="xx-small" position="left" />
3541
<Margin size="x-small" position="left" />
@@ -42,8 +48,10 @@ The base unit of all our spacing metrics is **4**.
4248
</Example>
4349

4450
## Location - Bottom
51+
4552
<Example title="bottom margins">
4653
<div>
54+
<Margin size="none" position="bottom" />
4755
<Margin size="xxx-small" position="bottom" />
4856
<Margin size="xx-small" position="bottom" />
4957
<Margin size="x-small" position="bottom" />
@@ -56,8 +64,10 @@ The base unit of all our spacing metrics is **4**.
5664
</Example>
5765

5866
## Location - Right
67+
5968
<Example title="right margins">
6069
<div>
70+
<Margin size="none" position="right" />
6171
<Margin size="xxx-small" position="right" />
6272
<Margin size="xx-small" position="right" />
6373
<Margin size="x-small" position="right" />
@@ -70,8 +80,10 @@ The base unit of all our spacing metrics is **4**.
7080
</Example>
7181

7282
## Location - Horizontal
83+
7384
<Example title="horizontal margins">
7485
<div>
86+
<Margin size="none" position="horizontal" />
7587
<Margin size="xxx-small" position="horizontal" />
7688
<Margin size="xx-small" position="horizontal" />
7789
<Margin size="x-small" position="horizontal" />
@@ -84,8 +96,10 @@ The base unit of all our spacing metrics is **4**.
8496
</Example>
8597

8698
## Location - Vertical
99+
87100
<Example title="vertical margins">
88101
<div>
102+
<Margin size="none" position="vertical" />
89103
<Margin size="xxx-small" position="vertical" />
90104
<Margin size="xx-small" position="vertical" />
91105
<Margin size="x-small" position="vertical" />
@@ -98,8 +112,10 @@ The base unit of all our spacing metrics is **4**.
98112
</Example>
99113

100114
## Location - Around
115+
101116
<Example title="around margins">
102117
<div>
118+
<Margin size="none" position="around" />
103119
<Margin size="xxx-small" position="around" />
104120
<Margin size="xx-small" position="around" />
105121
<Margin size="x-small" position="around" />

ui/utilities/margin/docs/Margin.jsx

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,18 @@
22
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
33

44
import React, { Component } from 'react';
5-
import ReactDOM from 'react-dom/server';
6-
import style from './Margin.scss';
5+
import './Margin.scss';
76
import classNames from 'classnames';
87
import CodeBlock from '../../../../shared/components/CodeBlock';
98

10-
const Redline = props => (
11-
<span className="doc-redline" style={{ width: props.width }}>
12-
<span />
13-
</span>
14-
);
15-
169
class Margin extends Component {
1710
render() {
18-
let margin;
1911
let { size, position } = this.props;
20-
const sizes = {
21-
'xxx-small': '0.125rem',
22-
'xx-small': '0.25rem',
23-
'x-small': '0.5rem',
24-
small: '0.75rem',
25-
medium: '1rem',
26-
large: '1.5rem',
27-
'x-large': '2rem',
28-
'xx-large': '3rem'
29-
};
30-
let widths = JSON.stringify(sizes);
31-
JSON.parse(widths, (key, value) => {
32-
if (key === size) {
33-
margin = value;
34-
}
35-
});
3612
let spacingClass = `slds-m-${position}_${size}`;
3713
return (
3814
<div className="docs-codeblock">
3915
<div className="docs-codeblock-example">
40-
<div className={classNames('doc-spacing')}>
16+
<div className="doc-spacing">
4117
<div
4218
className={classNames(
4319
'doc-margin doc-margin_primary',

0 commit comments

Comments
 (0)