Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 4280f90

Browse files
committed
build: Adds React 18 to peer deps ranges
1 parent 103fedf commit 4280f90

File tree

4 files changed

+99
-191
lines changed

4 files changed

+99
-191
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

README.md

+2-99
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,3 @@
1-
![ReactShadow](media/logo.png)
1+
This package is forked from [ReactShadow](https://github.com/Wildhoney/ReactShadow)@19.0.3, with only one modification to the original project: adding react 18 to the peer dependency.
22

3-
> Utilise Shadow DOM in React with all the benefits of style encapsulation.
4-
5-
![Travis](http://img.shields.io/travis/Wildhoney/ReactShadow.svg?style=flat-square)
6-
 
7-
![Coveralls](https://img.shields.io/coveralls/Wildhoney/ReactShadow.svg?style=flat-square)
8-
 
9-
![npm](http://img.shields.io/npm/v/react-shadow.svg?style=flat-square)
10-
 
11-
![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat-square)
12-
13-
- **npm**: `npm i react-shadow`
14-
- **yarn**: `yarn add react-shadow`
15-
- **Heroku**: [https://react-shadow.herokuapp.com/](https://react-shadow.herokuapp.com) ([alternative](https://react-shadow-2.herokuapp.com))
16-
17-
![Screenshot](media/screenshot.png)
18-
19-
---
20-
21-
## Getting Started
22-
23-
Creating the [shadow root](https://www.w3.org/TR/shadow-dom/) is as simple as using the default export to construct a shadow root using the node name provided – for example `root.div` would create a `div` as the host element, and a shadow root as its immediate descendant — all of the child elements would then be descendants of the shadow boundary.
24-
25-
```jsx
26-
import root from 'react-shadow';
27-
import styles from './styles.css';
28-
29-
export default function Quote() {
30-
return (
31-
<root.div className="quote">
32-
<q>There is strong shadow where there is much light.</q>
33-
<span className="author">― Johann Wolfgang von Goethe.</span>
34-
<style type="text/css">{styles}</style>
35-
</root.div>
36-
);
37-
}
38-
```
39-
40-
[![Edit react-shadow](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-shadow-by6bo?fontsize=14)
41-
42-
Applying styles requires either applying the styles directly to the component as a string, or importing the CSS documents as a string as part of your build process. You can then append the `style` component directly to your shadow boundary via your component's tree. In [the example](https://github.com/Wildhoney/ReactShadow/tree/master/example) we use the following Webpack configuration to import CSS documents as strings.
43-
44-
```javascript
45-
{
46-
test: /\.css$/,
47-
loader: ['to-string-loader', 'css-loader']
48-
}
49-
```
50-
51-
Alternatively you can use [`styled-components`](https://www.styled-components.com/) normally, as each time a shadow boundary is created, a new `StyleSheetManager` context is also created which will encapsulate all related styles in their corresponding shadow root &mdash; to use this `import react-shadow/styled-components` instead of `import react-shadow`, likewise if you'd like to use [`emotion`](https://emotion.sh/docs/styled) you can `import react-shadow/emotion`.
52-
53-
```javascript
54-
import root from 'react-shadow/styled-components';
55-
import root from 'react-shadow/emotion';
56-
57-
// ...
58-
59-
<root.section />;
60-
```
61-
62-
You may pass any props you like to the `root.*` component which will be applied directly to the host element, including event handlers and class names. There are also a handful of options that are used for the `attachShadow` invocation.
63-
64-
```javascript
65-
ShadowRoot.propTypes = {
66-
mode: PropTypes.oneOf(['open', 'closed']),
67-
delegatesFocus: PropTypes.bool,
68-
styleSheets: PropTypes.arrayOf(
69-
PropTypes.instanceOf(globalThis.CSSStyleSheet),
70-
),
71-
children: PropTypes.node,
72-
};
73-
74-
ShadowRoot.defaultProps = {
75-
mode: 'open',
76-
delegatesFocus: false,
77-
styleSheets: [],
78-
children: null,
79-
};
80-
```
81-
82-
In cases where you need the underlying element and its associated shadow boundary, you can use a standard `ref` which will be invoked with the host element &ndash; from that you can use `shadowRoot` to access its shadow root if the `mode` has been set to the default `open` value.
83-
84-
```javascript
85-
const node = useRef(null);
86-
87-
// ...
88-
89-
<root.section ref={node} />;
90-
```
91-
92-
Recently and at long last there has been some movement in introducing a [declarative shadow DOM](https://tomalec.github.io/declarative-shadow-dom/) which `react-shadow` _tentatively_ supports &ndash; as it's experimental, open to sudden spec changes, and React finds it difficult to rehydrate &ndash; by using the `ssr` prop.
93-
94-
```javascript
95-
const node = useRef(null);
96-
97-
// ...
98-
99-
<root.section ssr />;
100-
```
3+
If, like me, you [get an `ERESOLVE unable to resolve dependency tree error` when installing react-shadow using npm](https://github.com/Wildhoney/ReactShadow/pull/140#issuecomment-1326663553), then you can install this package instead.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "react-shadow",
2+
"name": "@hcfy/react-shadow",
33
"version": "19.0.3",
44
"description": "Utilise Shadow DOM in React with all the benefits of style encapsulation.",
55
"main": "react-shadow.js",
@@ -36,12 +36,12 @@
3636
},
3737
"peerDependencies": {
3838
"prop-types": "^15.0.0",
39-
"react": "^16.8.0 || ^17.0.0",
40-
"react-dom": "^16.0.0 || ^17.0.0"
39+
"react": "^16.8.0 || ^17.0.0|| ^18.0.0",
40+
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
4141
},
4242
"dependencies": {
4343
"humps": "^2.0.1",
44-
"react-use": "^15.3.3"
44+
"react-use": "^17.0.0"
4545
},
4646
"devDependencies": {
4747
"@babel/core": "^7.11.1",

0 commit comments

Comments
 (0)