-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc63b77
commit b4cee66
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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,38 @@ | ||
--- | ||
"@rhds/elements": minor | ||
--- | ||
⚛️ Added React wrapper components | ||
|
||
You can now more easily integrate RHDS elements into your React apps by importing our wrapper components | ||
|
||
First, make sure that you list `@lit/react` as a dependency in your project | ||
|
||
```sh | ||
npm install --save @lit/react | ||
``` | ||
|
||
Then import the element components you need and treat them like any other react component | ||
|
||
```js | ||
import { Tabs } from '@rhds/elements/react/rh-tabs/rh-tabs.js'; | ||
import { Tab } from '@rhds/elements/react/rh-tabs/rh-tab.js'; | ||
import { TabPanel } from '@rhds/elements/react/rh-tabs/rh-tab-panel.js'; | ||
|
||
import { useState } from 'react'; | ||
|
||
const tabs = [ | ||
{ heading: 'Hello Red Hat', content: 'Let\'s break down silos' }, | ||
{ heading: 'Web components', content: 'They work everywhere' } | ||
]; | ||
|
||
function App() { | ||
const [index, setExpanded] = useState(-1); | ||
return ( | ||
<span>expanded {expanded}</span> | ||
<Tabs>{tabs.map(({ heading, content }, i) => ( | ||
<Tab slot="tab" onExpand={() => setExpanded(i)}>{heading}</Tab> | ||
<TabPanel>{content}</TabPanel>))} | ||
</Tabs> | ||
); | ||
} | ||
``` |
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
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
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
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,11 @@ | ||
import { generateReactWrappers } from '@patternfly/pfe-tools/react/generate-wrappers.js'; | ||
|
||
const inURL = new URL('../custom-elements.json', import.meta.url); | ||
const outURL = new URL('../react/', import.meta.url); | ||
|
||
await generateReactWrappers(inURL, | ||
outURL, | ||
'@rhds/elements', | ||
'rh', | ||
'Rh'); | ||
|