Skip to content

Commit 57dd7dd

Browse files
committed
docs: add migration guide to v2 (#4076)
1 parent f9e90ff commit 57dd7dd

File tree

7 files changed

+105
-5
lines changed

7 files changed

+105
-5
lines changed

docs/public/style.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body {
1212
}
1313

1414
blockquote {
15-
border-left: 3px solid rgba(34, 36, 38, .15);
15+
border-left: 3px solid rgba(34, 36, 38, 0.15);
1616
margin-left: 0;
1717
padding-left: 10px;
1818
font-style: italic;
@@ -43,20 +43,20 @@ pre {
4343
margin: 0;
4444
}
4545

46-
code:not([class*="language-"]) {
46+
code:not([class*='language-']) {
4747
font-size: 87.5%;
4848
background-color: rgba(0, 0, 0, 0.04);
4949
border-radius: 3px;
5050
white-space: pre;
5151
display: inline-block;
5252
}
5353

54-
code:not([class*="language-"])::before {
54+
code:not([class*='language-'])::before {
5555
letter-spacing: -0.2em;
5656
content: '\00a0';
5757
}
5858

59-
code:not([class*="language-"])::after {
59+
code:not([class*='language-'])::after {
6060
letter-spacing: -0.2em;
6161
content: '\00a0';
6262
}
@@ -138,3 +138,13 @@ code:not([class*="language-"])::after {
138138
.carbon-poweredby:hover {
139139
color: #ddd;
140140
}
141+
142+
/* --- */
143+
144+
.token.deleted {
145+
color: #e2777a;
146+
}
147+
148+
.token.inserted {
149+
color: #7ec699;
150+
}

docs/src/components/CodeSnippet/CodeSnippet.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React from 'react'
55

66
// Order of PrismJS imports there is sensitive
77
import 'prismjs/components/prism-clike'
8+
import 'prismjs/components/prism-diff'
89
import 'prismjs/components/prism-json'
910
import 'prismjs/components/prism-markup'
1011
import 'prismjs/components/prism-bash'
@@ -23,6 +24,7 @@ const normalizeToString = (value) => {
2324

2425
const formatters = {
2526
bash: (val = '') => val.replace(/^[\w]/gm, '$$ $&'),
27+
diff: (val) => val,
2628
json: (val) => val,
2729
js: (val = '') => val,
2830
jsx: (val = '') => val,

docs/src/components/Document.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) =
1010
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no' />
1111

1212
<link rel='shortcut icon' type='image/x-icon' href='/logo.png' />
13-
<link rel='stylesheet' href={`/style.css?${versions.suir}`} />
1413
<link
1514
rel='stylesheet'
1615
href={`https://cdn.jsdelivr.net/npm/semantic-ui@${versions.sui}/dist/semantic.min.css`}
@@ -52,6 +51,8 @@ const Document = ({ Body, children, Head, Html, siteData: { dev, versions } }) =
5251
versions.react
5352
}/umd/react-dom-server.browser${dev ? '.development' : '.production.min'}.js`}
5453
/>
54+
55+
<link rel='stylesheet' href={`/style.css?${versions.suir}`} />
5556
</Head>
5657
<Body>{children}</Body>
5758
</Html>

docs/src/components/DocumentationPage/components.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ export const code = ({ className, children, fitted, formattable, label }) => (
2323
export const h1 = ({ children }) => <Header as='h1' content={children} textAlign='center' />
2424

2525
export const h2 = ({ children }) => <Header as='h2' content={children} dividing />
26+
27+
export const h3 = ({ children }) => <Header as='h3' content={children} />

docs/src/components/Sidebar/Sidebar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ class Sidebar extends Component {
223223
<Menu.Item as={Link} exact to='/prototypes' activeClassName='active'>
224224
Prototypes
225225
</Menu.Item>
226+
<Menu.Item as={Link} exact to='/migration-guide' activeClassName='active'>
227+
Migration guide to v2
228+
</Menu.Item>
226229
</Menu.Menu>
227230
</Menu.Item>
228231
<Menu.Item fitted>

docs/src/pages/MigrationGuide.mdx

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
export const meta = {
2+
title: 'Migration Guide',
3+
prevPage: { title: 'Prototypes', href: '/prototypes' },
4+
}
5+
6+
This is a reference for upgrading your application to v2 of Semantic UI React. While there's a lot covered here, you probably won't need to do everything for your app.
7+
8+
## Upgrade of `react-popper` for `Popup`
9+
10+
_Popper.js v1 is out of date, v2 was released in Dec 2019, time to upgrade 🚀_
11+
12+
### `offset` can't be specified as string anymore
13+
14+
Previously it was possible to pass different units to the offset prop as units. This behavior was changed and `offset` accepts a tuple or a function. Examples in our docs were also updated.
15+
16+
```diff
17+
<>
18+
- <Popup offset="50px" />
19+
+ <Popup offset={[50, 0]} />
20+
<br />
21+
- <Popup offset="-100%p" />
22+
+ <Popup offset={({ popper }) => [-popper.width, 0]} />
23+
</>
24+
```
25+
26+
### `popperModifiers` should be defined as array now
27+
28+
The `popperModifiers` prop should be defined as an array with changed format (see [Popper docs](https://popper.js.org/docs/v2/migration-guide/#10-update-modifiers)).
29+
30+
```diff
31+
-<Popup popperModifiers={{ preventOverflow: { padding: 0 } }} />
32+
+<Popup popperModifiers={[{ name: 'preventOverflow', options: { padding: 0 } }]} />
33+
```
34+
35+
## `Responsive` component was removed
36+
37+
`Responsive` component was deprecated in 1.1.0. There are two main reasons for the removal: there is no connection between breakpoints and pure SSR (server side rendering) support.
38+
39+
[@artsy/fresnel](https://github.com/artsy/fresnel) was proposed as a replacement as it properly handles SSR scenarios.
40+
41+
```diff
42+
+import { createMedia } from "@artsy/fresnel";
43+
import React from "react";
44+
-import { Responsive, Segment } from "semantic-ui-react";
45+
+import { Segment } from "semantic-ui-react";
46+
47+
+const AppMedia = createMedia({
48+
+ breakpoints: {
49+
+ mobile: 320,
50+
+ tablet: 768,
51+
+ computer: 992,
52+
+ largeScreen: 1200,
53+
+ widescreen: 1920
54+
+ }
55+
+});
56+
+const mediaStyles = AppMedia.createMediaStyle();
57+
+const { Media, MediaContextProvider } = AppMedia;
58+
59+
-const App = () => (
60+
- <Responsive as={Segment} {...Responsive.onlyMobile}>
61+
- Mobile
62+
- </Responsive>
63+
-)
64+
+const App = () => (
65+
+ <>
66+
+ <style>{mediaStyles}</style>
67+
+ <MediaContextProvider>
68+
+ <Segment as={Media} at="mobile">
69+
+ Mobile
70+
+ </Segment>
71+
+ </MediaContextProvider>
72+
+ </>
73+
+);
74+
```
75+
76+
The full migration guide is available in [Semantic-Org/Semantic-UI-React#4008](https://github.com/Semantic-Org/Semantic-UI-React/pull/4008), it contains more detailed explanation and examples for Next.js & Gatsby.
77+
78+
## `MountNode` component was removed
79+
80+
`MountNode` component was deprecated in 1.1.0. The main reason for the removal is that the component should not be a part of the public API as it solves our specific issue with the `Modal` component.
81+
Additional details are available in [Semantic-Org/Semantic-UI-React#4027](https://github.com/Semantic-Org/Semantic-UI-React/pull/4027).

docs/src/pages/Prototypes.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button, Card, Header, Image } from 'semantic-ui-react'
33
export const meta = {
44
title: 'Prototypes',
55
prevPage: { title: 'Layout examples', href: '/layouts' },
6+
nextPage: { title: 'Migration Guide', href: '/migration-guide' },
67
}
78

89
<Header as='h2' content='Integrations' subheader='Examples of integrations with other libraries' />

0 commit comments

Comments
 (0)