-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): add simple example of v10 and v11 being used together (…
…#12067) * docs(examples): add small incremental migration example * docs(examples): add small incremental migration example * docs(examples): remove unnecessary comment * chore(examples): run dedupe * docs(react): fix typos and code errors
- Loading branch information
Showing
20 changed files
with
471 additions
and
5 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+99.1 KB
...time-npm-7.18.3-1883c70fa6-db8526226a.zip → ...time-npm-7.18.9-28ca6b5f61-36dd736bab.zip
Binary file not shown.
Binary file added
BIN
+13.6 KB
.yarn/cache/@carbon-feature-flags-npm-0.7.0-7f192756d6-f16348fa78.zip
Binary file not shown.
Binary file added
BIN
+19.6 MB
.yarn/cache/@carbon-icons-react-npm-10.49.0-38655169d3-dd3aec2718.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.35 MB
.yarn/cache/carbon-components-react-npm-7.59.0-3db1ba9c08-7762d139df.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with | ||
[`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Incremental migration | ||
|
||
We have recently released a new version, v11, of our component library and a | ||
common question we receive is if users can adopt v11 incrementally and the | ||
answer is yes! If the burden of migrating to v11 is too big to take on all at | ||
once, but there are features of our latest release you want to take advantage | ||
of, it is likely that you can pull in just the parts you are wanting to use | ||
while keeping the rest of your Carbon usage the same. | ||
|
||
This example illustrates how v11 and v10 work together. | ||
|
||
## Getting Started | ||
|
||
First, run `yarn` or `npm install` and then run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the | ||
result. | ||
|
||
You can start editing the page by modifying `pages/index.js`. The page | ||
auto-updates as you edit the file. | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on | ||
[http://localhost:3000/api/hello](http://localhost:3000/api/hello). This | ||
endpoint can be edited in `pages/api/hello.js`. | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are | ||
treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead | ||
of React pages. | ||
|
||
## Sass | ||
|
||
First and foremost, if you want to use v11 styles in any capacity, you'll have | ||
to migrate to use `dart-sass`. `node-sass` has been deprecated and we migrated | ||
to `dart-sass` in v11. For more information about migrating, visit our docs | ||
[here](https://github.com/carbon-design-system/carbon/blob/main/docs/migration/v11.md#changing-from-node-sass-to-sass). | ||
|
||
## V10 and V11 | ||
|
||
This example is mainly v10, but it takes advantage of the new Stack component | ||
from v11 and uses v11's StructuredList component 🎉. StructuredList had a major | ||
accessibilty revamp in v11 that you might want to use and this examples shows | ||
you how. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js | ||
features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out | ||
[the Next.js GitHub repository](https://github.com/vercel/next.js/) - your | ||
feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the | ||
[Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) | ||
from the creators of Next.js. | ||
|
||
Check out our | ||
[Next.js deployment documentation](https://nextjs.org/docs/deployment) for more | ||
details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
}; | ||
|
||
module.exports = nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "incremental-migration", | ||
"private": true, | ||
"version": "0.12.0", | ||
"scripts": { | ||
"build": "next build", | ||
"dev": "next dev", | ||
"lint": "next lint", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@carbon/icons-react": "10.49.0", | ||
"@carbon/react": "^1.12.0", | ||
"carbon-components": "^10.57.0", | ||
"carbon-components-react": "^7.57.0", | ||
"carbon-icons": "^7.0.7", | ||
"next": "12.1.4", | ||
"react": "18.0.0", | ||
"react-dom": "18.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "8.12.0", | ||
"eslint-config-next": "12.1.4", | ||
"sass": "^1.51.0" | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import '../scss/styles.scss'; | ||
import React from 'react'; | ||
|
||
// eslint-disable-next-line react/prop-types | ||
function MyApp({ Component, pageProps }) { | ||
return <Component {...pageProps} />; | ||
} | ||
|
||
export default MyApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
import React from 'react'; | ||
import { | ||
Button, | ||
Content, | ||
Header, | ||
SkipToContent, | ||
HeaderName, | ||
Toggle, | ||
NumberInput, | ||
RadioButtonGroup, | ||
RadioButton, | ||
Search, | ||
Select, | ||
SelectItem, | ||
TextInput, | ||
TextArea, | ||
} from 'carbon-components-react'; | ||
import { | ||
StructuredListBody, | ||
StructuredListWrapper, | ||
StructuredListHead, | ||
StructuredListRow, | ||
StructuredListCell, | ||
Stack, | ||
} from '@carbon/react'; | ||
import Head from 'next/head'; | ||
import styles from '../scss/Home.module.css'; | ||
|
||
export default function Home() { | ||
const numberInputProps = { | ||
className: 'some-class', | ||
id: 'number-input-1', | ||
label: 'Number Input', | ||
min: 0, | ||
max: 100, | ||
value: 50, | ||
step: 10, | ||
}; | ||
|
||
const toggleProps = { | ||
className: 'some-class', | ||
}; | ||
|
||
const radioProps = { | ||
className: 'some-class', | ||
}; | ||
|
||
const searchProps = { | ||
className: 'some-class', | ||
}; | ||
|
||
const selectProps = { | ||
className: 'some-class', | ||
}; | ||
|
||
const TextInputProps = { | ||
className: 'some-class', | ||
id: 'test2', | ||
labelText: 'Text Input label', | ||
placeholder: 'Placeholder text', | ||
}; | ||
|
||
const textareaProps = { | ||
labelText: 'Text Area label', | ||
className: 'some-class', | ||
placeholder: 'Placeholder text', | ||
id: 'test5', | ||
cols: 50, | ||
rows: 4, | ||
}; | ||
|
||
const buttonEvents = { | ||
className: 'some-class', | ||
}; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Head> | ||
<title>Create Next App</title> | ||
<meta name="description" content="Generated by create next app" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</Head> | ||
|
||
<Header aria-label="IBM Platform Name"> | ||
<SkipToContent /> | ||
<HeaderName href="#" prefix="IBM"> | ||
[Platform] | ||
</HeaderName> | ||
</Header> | ||
<Content> | ||
<Stack gap={6}> | ||
<NumberInput {...numberInputProps} /> | ||
<Toggle {...toggleProps} id="toggle-1" /> | ||
<RadioButtonGroup | ||
onChange={() => {}} | ||
name="radio-button-group" | ||
defaultSelected="default-selected"> | ||
<RadioButton | ||
value="standard" | ||
id="radio-1" | ||
labelText="Standard Radio Button" | ||
{...radioProps} | ||
/> | ||
<RadioButton | ||
value="default-selected" | ||
labelText="Default Selected Radio Button" | ||
id="radio-2" | ||
{...radioProps} | ||
/> | ||
<RadioButton | ||
value="blue" | ||
labelText="Standard Radio Button" | ||
id="radio-3" | ||
{...radioProps} | ||
/> | ||
<RadioButton | ||
value="disabled" | ||
labelText="Disabled Radio Button" | ||
id="radio-4" | ||
disabled | ||
{...radioProps} | ||
/> | ||
</RadioButtonGroup> | ||
<StructuredListWrapper> | ||
<StructuredListHead> | ||
<StructuredListRow head> | ||
<StructuredListCell head>ColumnA</StructuredListCell> | ||
<StructuredListCell head>ColumnB</StructuredListCell> | ||
<StructuredListCell head>ColumnC</StructuredListCell> | ||
</StructuredListRow> | ||
</StructuredListHead> | ||
<StructuredListBody> | ||
<StructuredListRow> | ||
<StructuredListCell noWrap>Row 1</StructuredListCell> | ||
<StructuredListCell>Row 1</StructuredListCell> | ||
<StructuredListCell> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc | ||
dui magna, finibus id tortor sed, aliquet bibendum augue. | ||
Aenean posuere sem vel euismod dignissim. Nulla ut cursus | ||
dolor. Pellentesque vulputate nisl a porttitor interdum. | ||
</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell noWrap>Row 2</StructuredListCell> | ||
<StructuredListCell>Row 2</StructuredListCell> | ||
<StructuredListCell> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc | ||
dui magna, finibus id tortor sed, aliquet bibendum augue. | ||
Aenean posuere sem vel euismod dignissim. Nulla ut cursus | ||
dolor. Pellentesque vulputate nisl a porttitor interdum. | ||
</StructuredListCell> | ||
</StructuredListRow> | ||
</StructuredListBody> | ||
</StructuredListWrapper> | ||
<Search | ||
{...searchProps} | ||
id="search-1" | ||
labelText="Search" | ||
placeholder="Search" | ||
/> | ||
<Select | ||
{...selectProps} | ||
id="select-1" | ||
defaultValue="placeholder-item"> | ||
<SelectItem | ||
disabled | ||
hidden | ||
value="placeholder-item" | ||
text="Choose an option" | ||
/> | ||
<SelectItem value="option-1" text="Option 1" /> | ||
<SelectItem value="option-2" text="Option 2" /> | ||
<SelectItem value="option-3" text="Option 3" /> | ||
</Select> | ||
<TextInput {...TextInputProps} /> | ||
<TextArea {...textareaProps} /> | ||
<div className={styles.someClass}> | ||
<Button type="submit" {...buttonEvents}> | ||
Submit | ||
</Button> | ||
</div> | ||
</Stack> | ||
</Content> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.container { | ||
padding: 0 2rem; | ||
} | ||
|
||
.someClass { | ||
padding-top: 1rem; | ||
} | ||
|
||
@media (max-width: 600px) { | ||
.grid { | ||
width: 100%; | ||
flex-direction: column; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@use '@carbon/react/scss/components/structured-list'; | ||
@use '@carbon/react/scss/components/stack'; | ||
@import 'carbon-components/scss/globals/scss/styles'; |
Oops, something went wrong.