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 11.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 {
411 display : none ;
512 }
6- summary {
7- cursor : pointer ;
13+ .hide {
14+ display : inline ;
815 }
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 ;
1227 }
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 ;
3130 }
3231 }
32+ }
3333}
3434
3535.flex {
3636 display : flex ;
3737 justify-content : center ;
3838 align-items : center ;
3939 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 ;
4156}
42-
4357.demo {
4458 width : var (--max-width );
4559 max-width : 95vw ;
5367 & > * {
5468 flex-grow : 1 ;
5569 }
56-
70+
5771 img {
5872 display : block ;
5973 max-width : 500px ;
6579 h2 {
6680 text-align : center ;
6781 }
82+ button {
83+ cursor : pointer ;
84+ margin : 5px 10px ;
85+ }
6886}
6987
7088.preview {
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ import { WithSelector } from "./with-selectors";
99import withSelectorCode from "./with-selectors/with-selectors.tsx?raw" ;
1010import storeCode from "./with-selectors/store.ts?raw" ;
1111import 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" ;
1215
1316const basicExCode = [
1417 { filename : "counter.tsx" , code : counterCode } ,
@@ -17,7 +20,10 @@ const basicExCode = [
1720
1821const withSelectorExCode = [
1922 { filename : "store.ts" , code : storeCode } ,
23+ { filename : "header.tsx" , code : headerCode } ,
2024 { filename : "counter.tsx" , code : couter2Code } ,
25+ { filename : "counter-without-selectors.tsx" , code : counterWithoutSelectorscode } ,
26+ { filename : "user-data.tsx" , code : userDataCode } ,
2127 { filename : "with-selectors.tsx" , code : withSelectorCode } ,
2228] ;
2329
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ export function CounterWithoutSelectors() {
77 renderCount . current ++ ;
88 return (
99 < 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 >
1212 < p > Count: { count } </ p >
1313 < button onClick = { ( ) => setState ( state => ( { ...state , count : count + 1 } ) ) } > Increment</ button >
1414 < 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() {
77 renderCount . current ++ ;
88 return (
99 < 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 >
1212 < p > Count: { count } </ p >
1313 < button onClick = { ( ) => setState ( state => ( { ...state , count : count + 1 } ) ) } > Increment</ button >
1414 < button onClick = { ( ) => setState ( state => ( { ...state , count : count - 1 } ) ) } > Decrement</ button >
Original file line number Diff line number Diff line change 11import { useRef } from "react" ;
22import { useStore } from "./store" ;
3+ import styles from "../demo.module.scss" ;
34
45export function Header ( ) {
56 const [ { name } ] = useStore ( "name" ) ;
67 const renderCount = useRef ( 0 ) ;
78 renderCount . current ++ ;
89 return (
9- < header >
10+ < header className = { styles . header } >
1011 < h1 > My name is { name } </ h1 >
1112 < small >
1213 < i >
Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ export function WithSelector() {
88 return (
99 < div className = { styles . preview } >
1010 < Header />
11- < Counter />
12- < CounterWithoutSelectors />
13- < UserData />
11+ < div className = { styles . flex } >
12+ < Counter />
13+ < CounterWithoutSelectors />
14+ < UserData />
15+ </ div >
1416 </ div >
1517 ) ;
1618}
You can’t perform that action at this time.
0 commit comments