Skip to content

Commit bbc0b98

Browse files
connecting it up
1 parent 67e4cdc commit bbc0b98

File tree

7 files changed

+62
-56
lines changed

7 files changed

+62
-56
lines changed

playground/internal/react/bannerTitle.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ func bannerTitleComponent(props Props) *Element {
1515
Span(Props{
1616
`id`: `banner-title-sub`,
1717
},
18-
`GopherJS (`, version, `)`,
18+
// TODO(grantnelson-wf): Make this a link to the gopherjs repo
19+
`GopherJS `,
20+
),
21+
Span(Props{
22+
`id`: `banner-title-version`,
23+
},
24+
// TODO(grantnelson-wf): Make this version a link to release notes
25+
`(`+version+`)`,
1926
),
2027
)
2128
}

playground/internal/react/bindings.go

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -197,40 +197,26 @@ func (r *Ref) Call(name string, args ...any) {
197197
r.Current().Call(name, args...)
198198
}
199199

200-
// UseEffectNoDeps registers an effect function that is called after every render.
201-
// See: https://react.dev/reference/react/useEffect
202-
func UseEffectNoDeps(effect func()) {
203-
react().Call(`useEffect`, effect)
204-
}
205-
206200
// UseEffect registers an effect function that is called after rendering.
207201
// The effect is re-run whenever any of the dependencies change.
208-
// If no dependency are provided, the effect is only run once after the initial render.
202+
//
203+
// If nil is given for the dependencies, the effect is re-run after every render.
204+
// If an empty `[]any{}` is given for the dependencies, the effect is only run once after the initial render.
205+
//
209206
// See: https://react.dev/reference/react/useEffect
210-
func UseEffect(effect func(), deps ...any) {
211-
if len(deps) == 0 {
212-
deps = []any{}
213-
}
207+
func UseEffect(effect func(), deps []any) {
214208
react().Call(`useEffect`, effect, deps)
215209
}
216210

217-
// UseEffectNoDepsWithCleanup registers an effect function that is called after every render.
218-
// The effect function returns a cleanup function that is called before the effect
219-
// is re-run or when the component is unmounted.
220-
// See: https://react.dev/reference/react/useEffect
221-
func UseEffectNoDepsWithCleanup(effect func() func()) {
222-
react().Call(`useEffect`, effect)
223-
}
224-
225211
// UseEffectWithCleanup registers an effect function that is called after rendering.
226212
// The effect is re-run whenever any of the dependencies change.
227-
// If no dependency are provided, the effect is only run once after the initial render.
213+
//
214+
// If nil is given for the dependencies, the effect is re-run after every render.
215+
// If an empty `[]any{}` is given for the dependencies, the effect is only run once after the initial render.
216+
//
228217
// The effect function returns a cleanup function that is called before the effect
229218
// is re-run or when the component is unmounted.
230219
// See: https://react.dev/reference/react/useEffect
231220
func UseEffectWithCleanup(effect func() func(), deps ...any) {
232-
if len(deps) == 0 {
233-
deps = []any{}
234-
}
235221
react().Call(`useEffect`, effect, deps)
236222
}

playground/internal/react/codeBox.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func (cba *codeBoxAssistant) onInput(e *js.Object) {
6464
}
6565

6666
func (cba *codeBoxAssistant) onKeyDown(e *js.Object) {
67+
// TODO(grantnelson-wf): Maybe handle Shift+Tab for un-indenting the current line.
68+
// TODO(grantnelson-wf): Handle Ctrl+/ for commenting/uncommenting the current line or selection.
69+
// TODO(grantnelson-wf): Handle Ctrl+S for saving the code, just run formatting, or just ignore it.
70+
// TODO(grantnelson-wf): Maybe handle auto-text like `/*` adds `*/`, `"` adds another `"`, `[` adds `]`, etc.
6771
if cba.handleKeyDown(e.Get(`keyCode`).Int()) {
6872
e.Call(`preventDefault`)
6973
}

playground/internal/react/playground.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ func Playground() *Element {
3030

3131
UseEffect(func() {
3232
setDataTheme(lightTheme)
33-
}, lightTheme)
33+
}, []any{lightTheme})
3434

3535
UseEffect(func() {
3636
// code changed so clear share URL
3737
setShareUrl(``)
3838
getLocation().Set(`hash`, ``)
3939
println("Code changed, cleared share URL") // TODO(grantnelson-wf): Remove debug
40-
}, code)
40+
}, []any{code})
4141

42-
UseEffect(pa.initCode)
42+
UseEffect(pa.initCode, []any{})
4343

4444
/* TODO(grantnelson-wf): Implement hashchange loading
4545
dom.GetWindow().Top().AddEventListener("hashchange", false, func(event dom.Event) {

playground/internal/react/shareUrlControl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func shareUrlComponent(props Props) *Element {
4040
`type`: `text`,
4141
`className`: className,
4242
`ref`: shareUrlRef,
43-
`value`: `Hello!`, //shareUrl, // TODO(grantnelson): Fix
43+
`value`: shareUrl,
4444
`readOnly`: true,
4545
`onFocus`: onShareUrlFocus,
4646
}),

playground/playground.css

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
11
:root {
22
--color-banner-title-text: black;
33
--color-banner-background: white;
4+
45
--color-code-text: black;
5-
--color-code-background: #ebdac7;
6+
--color-code-background: #EBDAC7;
67
--color-code-box-borders: black;
78
--color-line-nums-text: #888;
8-
--color-line-nums-background: #ebdac7;
9+
--color-line-nums-background: #EBDAC7;
910
--color-code-line-nums-border: black;
11+
1012
--color-output-normal-text: black;
11-
--color-output-normal-background: #ddd;
13+
--color-output-normal-background: #DDD;
1214
--color-output-error-text: #800;
13-
--color-output-error-background: #fcc;
14-
--color-run-button-background: #eee;
15-
--color-run-button-boarder: #ccc;
16-
--color-run-button-text: #222;
17-
--color-run-button-hover-background: #666;
18-
--color-run-button-hover-boarder: #ccc;
19-
--color-run-button-hover-text: #fff;
20-
--color-buttons-background: #eee;
21-
--color-buttons-boarder: #ccc;
15+
--color-output-error-background: #FCC;
16+
17+
--color-run-button-background: #FFF5D5;
18+
--color-run-button-boarder: #0E6A8A;
19+
--color-run-button-text: #0E6A8A;
20+
--color-run-button-hover-background: #0E6A8A;
21+
--color-run-button-hover-boarder: #0E6A8A;
22+
--color-run-button-hover-text: #FFF5D5;
23+
24+
--color-buttons-background: #EEE;
25+
--color-buttons-boarder: #CCC;
2226
--color-buttons-text: #222;
23-
--color-buttons-hover-background: #666;
24-
--color-buttons-hover-boarder: #ccc;
25-
--color-buttons-hover-text: #fff;
26-
--color-share-url-background: #eee;
27-
--color-share-url-boarder: #ccc;
27+
--color-buttons-hover-background: #0E6A8A;
28+
--color-buttons-hover-boarder: #0E6A8A;
29+
--color-buttons-hover-text: #FFF5D5;
30+
31+
--color-share-url-background: #EEE;
32+
--color-share-url-boarder: #CCC;
2833
--color-share-url-text: black;
29-
--color-toggle-background: #ccc;
30-
--color-toggle-background-checked: #ccc;
31-
--color-toggle-foreground: #333;
32-
--color-toggle-foreground-checked: #333;
34+
35+
--color-toggle-background: #CCC;
36+
--color-toggle-background-checked: #0E6A8A;
37+
--color-toggle-foreground: #0E6A8A;
38+
--color-toggle-foreground-checked: #FFF5D5;
3339

3440
--font-family-banner-title: Arial, sans;
3541
--font-size-banner-title: 32px;
3642
--font-size-banner-title-sub: 24px;
43+
--font-size-banner-title-version: 24px;
3744
--font-family-controls: sans-serif;
3845
--font-size-controls: 16px;
3946
--size-toggle-box: 30px;
@@ -88,6 +95,10 @@ html, body {
8895
font-size: var(--font-size-banner-title-sub);
8996
}
9097

98+
#banner-title-version {
99+
font-size: var(--font-size-banner-title-version);
100+
}
101+
91102
/* The part of the banner containing the buttons and controls */
92103
#controls {
93104
display: flex;
@@ -104,6 +115,7 @@ html, body {
104115
border-radius: 5px;
105116
font-family: var(--font-family-controls);
106117
font-size: var(--font-size-controls);
118+
/* TODO(grantnelson-wf): Add some shadow, like box-shadow: 5px 10px 10px #888888;*/
107119
}
108120

109121
/* The run code button */

playground/playground.js

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)