File tree Expand file tree Collapse file tree 6 files changed +63
-36
lines changed
packages/shared/src/client/demo Expand file tree Collapse file tree 6 files changed +63
-36
lines changed Original file line number Diff line number Diff line change 1
1
.codeDisplay {
2
- padding : 10px ;
3
- .hide {
2
+ padding : 10px ;
3
+ .hide {
4
+ display : none ;
5
+ }
6
+ summary {
7
+ cursor : pointer ;
8
+ }
9
+ & [open ] {
10
+ .show {
4
11
display : none ;
5
12
}
6
- summary {
7
- cursor : pointer ;
13
+ .hide {
14
+ display : inline ;
8
15
}
9
- & [open ] {
10
- .show {
11
- display : none ;
16
+ }
17
+ .tabs {
18
+ margin-bottom : -10px ;
19
+ text-wrap : nowrap ;
20
+ overflow : auto ;
21
+ button {
22
+ all : unset ;
23
+ cursor : pointer ;
24
+ padding : 10px 20px ;
25
+ & .active {
26
+ background : #2465 ;
12
27
}
13
- .hide {
14
- display : inline ;
15
- }
16
- }
17
- .tabs {
18
- margin-bottom : -10px ;
19
- text-wrap : nowrap ;
20
- overflow : auto ;
21
- button {
22
- all : unset ;
23
- cursor : pointer ;
24
- padding : 10px 20px ;
25
- & .active {
26
- background : #2465 ;
27
- }
28
- & :hover {
29
- background : #2495 ;
30
- }
28
+ & :hover {
29
+ background : #2495 ;
31
30
}
32
31
}
32
+ }
33
33
}
34
34
35
35
.flex {
36
36
display : flex ;
37
37
justify-content : center ;
38
38
align-items : center ;
39
39
flex-wrap : wrap ;
40
- gap : 20px ;
40
+ gap : 25px ;
41
+ & > * {
42
+ box-shadow : 0 0 5px red ;
43
+ padding : 20px ;
44
+ border-radius : 10px ;
45
+ }
46
+ }
47
+ .header {
48
+ display : flex ;
49
+ box-shadow : 0 0 5px red ;
50
+ align-items : center ;
51
+ margin : 0 -30px ;
52
+ margin-bottom : 30px ;
53
+ padding : 0 30px ;
54
+ justify-content : center ;
55
+ gap : 35px ;
41
56
}
42
-
43
57
.demo {
44
58
width : var (--max-width );
45
59
max-width : 95vw ;
53
67
& > * {
54
68
flex-grow : 1 ;
55
69
}
56
-
70
+
57
71
img {
58
72
display : block ;
59
73
max-width : 500px ;
65
79
h2 {
66
80
text-align : center ;
67
81
}
82
+ button {
83
+ cursor : pointer ;
84
+ margin : 5px 10px ;
85
+ }
68
86
}
69
87
70
88
.preview {
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ import { WithSelector } from "./with-selectors";
9
9
import withSelectorCode from "./with-selectors/with-selectors.tsx?raw" ;
10
10
import storeCode from "./with-selectors/store.ts?raw" ;
11
11
import couter2Code from "./with-selectors/counter.tsx?raw" ;
12
+ import counterWithoutSelectorscode from "./with-selectors/counter-without-selectors.tsx?raw" ;
13
+ import headerCode from "./with-selectors/header.tsx?raw" ;
14
+ import userDataCode from "./with-selectors/user-data.tsx?raw" ;
12
15
13
16
const basicExCode = [
14
17
{ filename : "counter.tsx" , code : counterCode } ,
@@ -17,7 +20,10 @@ const basicExCode = [
17
20
18
21
const withSelectorExCode = [
19
22
{ filename : "store.ts" , code : storeCode } ,
23
+ { filename : "header.tsx" , code : headerCode } ,
20
24
{ filename : "counter.tsx" , code : couter2Code } ,
25
+ { filename : "counter-without-selectors.tsx" , code : counterWithoutSelectorscode } ,
26
+ { filename : "user-data.tsx" , code : userDataCode } ,
21
27
{ filename : "with-selectors.tsx" , code : withSelectorCode } ,
22
28
] ;
23
29
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ export function CounterWithoutSelectors() {
7
7
renderCount . current ++ ;
8
8
return (
9
9
< div >
10
- < h1 > Counter Without Selectors</ h1 >
11
- < h2 > Rerender is triggered every time the state changes.</ h2 >
10
+ < h2 > Counter Without Selectors</ h2 >
11
+ < p > Rerender is triggered every time the state changes.</ p >
12
12
< p > Count: { count } </ p >
13
13
< button onClick = { ( ) => setState ( state => ( { ...state , count : count + 1 } ) ) } > Increment</ button >
14
14
< button onClick = { ( ) => setState ( state => ( { ...state , count : count - 1 } ) ) } > Decrement</ button >
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ export function Counter() {
7
7
renderCount . current ++ ;
8
8
return (
9
9
< div >
10
- < h1 > Counter With Selectors</ h1 >
11
- < h2 > Rerender is triggered by RGS only when count changes.</ h2 >
10
+ < h2 > Counter With Selectors</ h2 >
11
+ < p > Rerender is triggered by RGS only when count changes.</ p >
12
12
< p > Count: { count } </ p >
13
13
< button onClick = { ( ) => setState ( state => ( { ...state , count : count + 1 } ) ) } > Increment</ button >
14
14
< button onClick = { ( ) => setState ( state => ( { ...state , count : count - 1 } ) ) } > Decrement</ button >
Original file line number Diff line number Diff line change 1
1
import { useRef } from "react" ;
2
2
import { useStore } from "./store" ;
3
+ import styles from "../demo.module.scss" ;
3
4
4
5
export function Header ( ) {
5
6
const [ { name } ] = useStore ( "name" ) ;
6
7
const renderCount = useRef ( 0 ) ;
7
8
renderCount . current ++ ;
8
9
return (
9
- < header >
10
+ < header className = { styles . header } >
10
11
< h1 > My name is { name } </ h1 >
11
12
< small >
12
13
< i >
Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ export function WithSelector() {
8
8
return (
9
9
< div className = { styles . preview } >
10
10
< Header />
11
- < Counter />
12
- < CounterWithoutSelectors />
13
- < UserData />
11
+ < div className = { styles . flex } >
12
+ < Counter />
13
+ < CounterWithoutSelectors />
14
+ < UserData />
15
+ </ div >
14
16
</ div >
15
17
) ;
16
18
}
You can’t perform that action at this time.
0 commit comments