Skip to content

Commit d558138

Browse files
committed
Add global selector example
1 parent e2a95de commit d558138

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/components/App.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
22

33
import ScopedSelectors from './ScopedSelectors/ScopedSelectors';
4+
import GlobalSelectors from './GlobalSelectors/GlobalSelectors';
45
import ClassInheritance from './ClassInheritance/ClassInheritance';
56
import InheritanceOverrides from './InheritanceOverrides/InheritanceOverrides';
67
import ScopedAnimations from './ScopedAnimations/ScopedAnimations';
@@ -34,6 +35,11 @@ export default class App extends Component {
3435
<p>The animation's keyframes are private to the animations module, only exposed publicly via a class which this component inherits from.</p>
3536
<ScopedAnimations />
3637

38+
<h2>Global Selectors</h2>
39+
<p>Although they should be used as sparingly as possible, <strong>global selectors are still available when required.</strong></p>
40+
<p>The following component styles all <strong>&lt;p&gt;</strong> tags nested inside it.</p>
41+
<GlobalSelectors />
42+
3743
</div>
3844
);
3945
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.root {
2+
border-width: 2px;
3+
border-style: solid;
4+
border-color: brown;
5+
padding: 0 20px;
6+
margin: 0 6px;
7+
max-width: 400px;
8+
}
9+
10+
.root :global p {
11+
color: brown;
12+
font-size: 24px;
13+
font-family: helvetica, arial, sans-serif;
14+
font-weight: 600;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import styles from './GlobalSelectors.css';
2+
3+
import React, { Component } from 'react';
4+
5+
export default class GlobalSelectors extends Component {
6+
7+
render() {
8+
return (
9+
<div className={styles.root}>
10+
<p>Global Selectors</p>
11+
</div>
12+
);
13+
}
14+
15+
};

0 commit comments

Comments
 (0)