Skip to content

Commit d902af9

Browse files
committed
docs: update documentation
1 parent 7a74c55 commit d902af9

File tree

5 files changed

+165
-82
lines changed

5 files changed

+165
-82
lines changed

packages/docs/content/components/spinner.mdx

Lines changed: 101 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,131 @@ For accessibility purposes, each loader here includes `role="status"` and a nest
1919

2020
Use the border spinners for a lightweight loading indicator.
2121

22-
## Basic usage
23-
2422
```jsx preview
25-
<CSpinner/>
23+
<CSpinner/>
2624
```
2725

2826
### Colors
2927

3028
The border spinner uses `currentColor` for its `border-color`. You can use any of our text color utilities on the standard spinner.
3129

3230
```jsx preview
33-
<CSpinner color="primary"/>
34-
<CSpinner color="secondary"/>
35-
<CSpinner color="success"/>
36-
<CSpinner color="danger"/>
37-
<CSpinner color="warning"/>
38-
<CSpinner color="info"/>
39-
<CSpinner color="light"/>
40-
<CSpinner color="dark"/>
31+
<CSpinner color="primary" />
32+
<CSpinner color="secondary" />
33+
<CSpinner color="success" />
34+
<CSpinner color="danger" />
35+
<CSpinner color="warning" />
36+
<CSpinner color="info" />
37+
<CSpinner color="light" />
38+
<CSpinner color="dark" />
4139
```
4240

4341
## Growing spinner
4442

4543
If you don't fancy a border spinner, switch to the grow spinner. While it doesn't technically spin, it does repeatedly grow!
4644

4745
```jsx preview
48-
<CSpinner variant="grow"/>
46+
<CSpinner variant="grow" />
4947
```
5048

5149
Once again, this spinner is built with `currentColor`, so you can easily change its appearance. Here it is in blue, along with the supported variants.
5250

5351
```jsx preview
54-
<CSpinner color="primary" variant="grow"/>
55-
<CSpinner color="secondary" variant="grow"/>
56-
<CSpinner color="success" variant="grow"/>
57-
<CSpinner color="danger" variant="grow"/>
58-
<CSpinner color="warning" variant="grow"/>
59-
<CSpinner color="info" variant="grow"/>
60-
<CSpinner color="light" variant="grow"/>
61-
<CSpinner color="dark" variant="grow"/>
52+
<CSpinner color="primary" variant="grow" />
53+
<CSpinner color="secondary" variant="grow" />
54+
<CSpinner color="success" variant="grow" />
55+
<CSpinner color="danger" variant="grow" />
56+
<CSpinner color="warning" variant="grow" />
57+
<CSpinner color="info" variant="grow" />
58+
<CSpinner color="light" variant="grow" />
59+
<CSpinner color="dark" variant="grow" />
60+
```
61+
62+
## Alignment
63+
64+
CoreUI React spinners are built with `rems`, `currentColor`, and `display: inline-flex`. This means they can easily be resized, recolored, and quickly aligned.
65+
66+
### Margin
67+
68+
Use [margin utilities](https://coreui.io/docs/utilities/spacing/#margin-and-padding) like `.m-5` for easy spacing.
69+
70+
```jsx preview
71+
<CSpinner className="m-5" />
72+
```
73+
74+
### Placement
75+
76+
Use [flexbox utilities][https://coreui.io/docs/utilities/flex/], [float utilities][https://coreui.io/docs/utilities/float/], or [text alignment][https://coreui.io/docs/utilities/text/] utilities to place spinners exactly where you need them in any situation.
77+
78+
#### Flex
79+
80+
```jsx preview
81+
<div className="d-flex justify-content-center">
82+
<CSpinner />
83+
</div>
84+
```
85+
86+
```jsx preview
87+
<div className="d-flex align-items-center">
88+
<strong role="status">Loading...</strong>
89+
<CSpinner className="ms-auto" />
90+
</div>
91+
```
92+
93+
#### Floats
94+
95+
```jsx preview
96+
<div className="clearfix">
97+
<CSpinner className="float-end" />
98+
</div>
99+
```
100+
101+
#### Text align
102+
103+
```jsx preview
104+
<div className="text-center">
105+
<CSpinner />
106+
</div>
62107
```
63108

64109
## Size
65110

66-
Add `size="sm"`property` to make a smaller spinner that can quickly be used within other components.
111+
Add `size="sm"` property to make a smaller spinner that can quickly be used within other components.
67112

68113
```jsx preview
69-
<CSpinner size="sm"/>
70-
<CSpinner size="sm" variant="grow"/>
114+
<CSpinner size="sm" />
115+
<CSpinner size="sm" variant="grow" />
116+
```
117+
118+
Or, use custom CSS or inline styles to change the dimensions as needed.
119+
120+
```jsx preview
121+
<CSpinner size="sm" style={{ width: '3rem', height: '3rem'}}/>
122+
<CSpinner size="sm" variant="grow" style={{ width: '3rem', height: '3rem'}}/>
71123
```
72124

73125
## Buttons
74126

75127
Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.
76128

77129
```jsx preview
78-
<CButton disabled>
79-
<CSpinner component="span" size="sm" aria-hidden="true"/>
80-
</CButton>
81-
<CButton disabled>
82-
<CSpinner component="span" size="sm" aria-hidden="true"/>
83-
Loading...
84-
</CButton>
130+
<CButton disabled>
131+
<CSpinner component="span" size="sm" aria-hidden="true" />
132+
</CButton>
133+
<CButton disabled>
134+
<CSpinner component="span" size="sm" aria-hidden="true" />
135+
Loading...
136+
</CButton>
85137
```
86138

87139
```jsx preview
88-
<CButton disabled>
89-
<CSpinner component="span" size="sm" variant="grow" aria-hidden="true"/>
90-
</CButton>
91-
<CButton disabled>
92-
<CSpinner component="span" size="sm" variant="grow" aria-hidden="true"/>
93-
Loading...
94-
</CButton>
140+
<CButton disabled>
141+
<CSpinner component="span" size="sm" variant="grow" aria-hidden="true" />
142+
</CButton>
143+
<CButton disabled>
144+
<CSpinner component="span" size="sm" variant="grow" aria-hidden="true" />
145+
Loading...
146+
</CButton>
95147
```
96148

97149
## Customizing
@@ -102,15 +154,15 @@ React spinners use local CSS variables on `.spinner-border` and `.spinner-grow`
102154

103155
Border spinner variables:
104156

105-
<ScssDocs file="_spinners.scss" capture="spinner-border-css-vars"/>
157+
<ScssDocs file="_spinners.scss" capture="spinner-border-css-vars" />
106158

107159
Growing spinner variables:
108160

109-
<ScssDocs file="_spinners.scss" capture="spinner-grow-css-vars"/>
161+
<ScssDocs file="_spinners.scss" capture="spinner-grow-css-vars" />
110162

111163
For both spinners, small spinner modifier classes are used to update the values of these CSS variables as needed. For example, the `.spinner-border-sm` class does the following:
112164

113-
<ScssDocs file="_spinners.scss" capture="spinner-border-sm-css-vars"/>
165+
<ScssDocs file="_spinners.scss" capture="spinner-border-sm-css-vars" />
114166

115167
#### How to use CSS variables
116168

@@ -124,7 +176,15 @@ return <CSpinner style={vars}>...</CSpinner>
124176

125177
### SASS variables
126178

127-
<ScssDocs file="_variables.scss" capture="spinner-variables"/>
179+
<ScssDocs file="_variables.scss" capture="spinner-variables" />
180+
181+
### Keyframes
182+
183+
Used for creating the CSS animations for our spinners. Included in `_spinners.scss`.
184+
185+
<ScssDocs file="_spinners.scss" capture="spinner-border-keyframes" />
186+
187+
<ScssDocs file="_spinners.scss" capture="spinner-grow-keyframes" />
128188

129189
## API
130190

packages/docs/content/layout/gutters.mdx

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@ import { CCol, CContainer, CRow } from '@coreui/react/src/index'
2020

2121
`{breakpoint}={{ gutterX: * }}` props can be used to control the horizontal gutter widths. The `<CContainer>` or `<CContainer fluid>` parent may need to be adjusted if larger gutters are used too to avoid unwanted overflow, using a matching padding utility. For example, in the following example we've increased the padding with `.px-4`:
2222

23-
```jsx preview
23+
```jsx preview className="docs-example m-0 border-0 docs-example-cols"
2424
<CContainer className="px-4">
2525
<CRow xs={{ gutterX: 5 }}>
2626
<CCol>
27-
<div className="p-3 border bg-light">Custom column padding</div>
27+
<div className="p-3">Custom column padding</div>
2828
</CCol>
2929
<CCol>
30-
<div className="p-3 border bg-light">Custom column padding</div>
30+
<div className="p-3">Custom column padding</div>
3131
</CCol>
3232
</CRow>
3333
</CContainer>
3434
```
3535

3636
An alternative solution is to add a wrapper around the `<CRow>` with the `.overflow-hidden` class:
3737

38-
```jsx preview
38+
```jsx preview className="docs-example m-0 border-0 docs-example-cols"
3939
<CContainer className="overflow-hidden">
4040
<CRow xs={{ gutterX: 5 }}>
4141
<CCol>
42-
<div className="p-3 border bg-light">Custom column padding</div>
42+
<div className="p-3">Custom column padding</div>
4343
</CCol>
4444
<CCol>
45-
<div className="p-3 border bg-light">Custom column padding</div>
45+
<div className="p-3">Custom column padding</div>
4646
</CCol>
4747
</CRow>
4848
</CContainer>
@@ -52,20 +52,20 @@ An alternative solution is to add a wrapper around the `<CRow>` with the `.overf
5252

5353
`{breakpoint}={{ gutterY: * }}` props can be used to control the vertical gutter widths. Like the horizontal gutters, the vertical gutters can cause some overflow below the `<CRow>` at the end of a page. If this occurs, you add a wrapper around `<CRow>` with the `.overflow-hidden` class:
5454

55-
```jsx preview
55+
```jsx preview className="docs-example m-0 border-0 docs-example-cols"
5656
<CContainer className="overflow-hidden">
5757
<CRow xs={{ gutterY: 5 }}>
5858
<CCol xs={{ span: 6 }}>
59-
<div className="p-3 border bg-light">Custom column padding</div>
59+
<div className="p-3">Custom column padding</div>
6060
</CCol>
6161
<CCol xs={{ span: 6 }}>
62-
<div className="p-3 border bg-light">Custom column padding</div>
62+
<div className="p-3">Custom column padding</div>
6363
</CCol>
6464
<CCol xs={{ span: 6 }}>
65-
<div className="p-3 border bg-light">Custom column padding</div>
65+
<div className="p-3">Custom column padding</div>
6666
</CCol>
6767
<CCol xs={{ span: 6 }}>
68-
<div className="p-3 border bg-light">Custom column padding</div>
68+
<div className="p-3">Custom column padding</div>
6969
</CCol>
7070
</CRow>
7171
</CContainer>
@@ -75,20 +75,20 @@ An alternative solution is to add a wrapper around the `<CRow>` with the `.overf
7575

7676
`{breakpoint}={{ gutter: * }}` props can be used to control the horizontal gutter widths, for the following example we use a smaller gutter width, so there won't be a need to add the `.overflow-hidden` wrapper class.
7777

78-
```jsx preview
78+
```jsx preview className="docs-example m-0 border-0 docs-example-cols"
7979
<CContainer>
8080
<CRow xs={{ gutter: 2 }}>
8181
<CCol xs={{ span: 6 }}>
82-
<div className="p-3 border bg-light">Custom column padding</div>
82+
<div className="p-3">Custom column padding</div>
8383
</CCol>
8484
<CCol xs={{ span: 6 }}>
85-
<div className="p-3 border bg-light">Custom column padding</div>
85+
<div className="p-3">Custom column padding</div>
8686
</CCol>
8787
<CCol xs={{ span: 6 }}>
88-
<div className="p-3 border bg-light">Custom column padding</div>
88+
<div className="p-3">Custom column padding</div>
8989
</CCol>
9090
<CCol xs={{ span: 6 }}>
91-
<div className="p-3 border bg-light">Custom column padding</div>
91+
<div className="p-3">Custom column padding</div>
9292
</CCol>
9393
</CRow>
9494
</CContainer>
@@ -98,38 +98,38 @@ An alternative solution is to add a wrapper around the `<CRow>` with the `.overf
9898

9999
Gutter props can also be added to [row columns](../layout/grid#row-columns). In the following example, we use responsive row columns and responsive gutter props.
100100

101-
```jsx preview
101+
```jsx preview className="docs-example m-0 border-0 docs-example-cols"
102102
<CContainer>
103103
<CRow xs={{ cols:2, gutter: 2 }} lg={{ cols: 5, gutter: 3}}>
104104
<CCol>
105-
<div className="p-3 border bg-light">Row column</div>
105+
<div className="p-3">Row column</div>
106106
</CCol>
107107
<CCol>
108-
<div className="p-3 border bg-light">Row column</div>
108+
<div className="p-3">Row column</div>
109109
</CCol>
110110
<CCol>
111-
<div className="p-3 border bg-light">Row column</div>
111+
<div className="p-3">Row column</div>
112112
</CCol>
113113
<CCol>
114-
<div className="p-3 border bg-light">Row column</div>
114+
<div className="p-3">Row column</div>
115115
</CCol>
116116
<CCol>
117-
<div className="p-3 border bg-light">Row column</div>
117+
<div className="p-3">Row column</div>
118118
</CCol>
119119
<CCol>
120-
<div className="p-3 border bg-light">Row column</div>
120+
<div className="p-3">Row column</div>
121121
</CCol>
122122
<CCol>
123-
<div className="p-3 border bg-light">Row column</div>
123+
<div className="p-3">Row column</div>
124124
</CCol>
125125
<CCol>
126-
<div className="p-3 border bg-light">Row column</div>
126+
<div className="p-3">Row column</div>
127127
</CCol>
128128
<CCol>
129-
<div className="p-3 border bg-light">Row column</div>
129+
<div className="p-3">Row column</div>
130130
</CCol>
131131
<CCol>
132-
<div className="p-3 border bg-light">Row column</div>
132+
<div className="p-3">Row column</div>
133133
</CCol>
134134
</CRow>
135135
</CContainer>
@@ -143,13 +143,27 @@ The gutters between columns in our predefined grid props can be removed with `{b
143143

144144
In practice, here's how it looks. Note you can continue to use this with all other predefined grid props (including column widths, responsive tiers, reorders, and more).
145145

146-
```jsx preview
147-
<div className="docs-example-row">
148-
<CRow xs={{ gutter: 0 }}>
149-
<CCol sm={6} md={8}>.col-sm-6 .col-md-8</CCol>
150-
<CCol xs={6} md={4}>.col-6 .col-md-4</CCol>
151-
</CRow>
152-
</div>
146+
```jsx preview className="docs-example m-0 border-0 docs-example-row"
147+
<CRow xs={{ gutter: 0 }}>
148+
<CCol sm={6} md={8}>.col-sm-6 .col-md-8</CCol>
149+
<CCol xs={6} md={4}>.col-6 .col-md-4</CCol>
150+
</CRow>
151+
```
152+
153+
## Change the gutters
154+
155+
Classes are built from the `$gutters` Sass map which is inherited from the `$spacers` Sass map.
156+
157+
```scss
158+
$grid-gutter-width: 1.5rem;
159+
$gutters: (
160+
0: 0,
161+
1: $spacer * .25,
162+
2: $spacer * .5,
163+
3: $spacer,
164+
4: $spacer * 1.5,
165+
5: $spacer * 3,
166+
);
153167
```
154168

155169
## API

packages/docs/src/components/CodeBlock.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React, { FC } from 'react'
2-
import { Highlight } from 'prism-react-renderer'
2+
import { Highlight, Prism } from 'prism-react-renderer'
33

44
interface CodeBlockProps {
55
children: any // eslint-disable-line @typescript-eslint/no-explicit-any
66
}
77

88
const CodeBlock: FC<CodeBlockProps> = ({ children }) => {
9+
;(typeof global === 'undefined' ? window : global).Prism = Prism
10+
// eslint-disable-next-line unicorn/prefer-module
11+
require('prismjs/components/prism-bash')
12+
require('prismjs/components/prism-scss')
913
const _children = children && children.props.children
1014
const language = children.props.className
1115
? children.props.className.replace(/language-/, '')

0 commit comments

Comments
 (0)