-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
ブラウザでのテストを追加する
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
font-family: sans-serif; | ||
margin: 20px; | ||
padding: 0; | ||
} | ||
|
||
h1 { | ||
margin-top: 0; | ||
font-size: 22px; | ||
} | ||
|
||
h2 { | ||
margin-top: 0; | ||
font-size: 20px; | ||
} | ||
|
||
h3 { | ||
margin-top: 0; | ||
font-size: 18px; | ||
} | ||
|
||
h4 { | ||
margin-top: 0; | ||
font-size: 16px; | ||
} | ||
|
||
h5 { | ||
margin-top: 0; | ||
font-size: 14px; | ||
} | ||
|
||
h6 { | ||
margin-top: 0; | ||
font-size: 12px; | ||
} | ||
|
||
code { | ||
font-size: 1.2em; | ||
} | ||
|
||
ul { | ||
padding-inline-start: 20px; | ||
} | ||
|
||
.avatar { | ||
border-radius: 50%; | ||
} | ||
|
||
.large { | ||
border: 4px solid gold; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React | ||
import JavaScriptKit | ||
import SRTDOM | ||
import BRTSupport | ||
|
||
// https://ja.react.dev/learn#responding-to-events | ||
|
||
struct MyButton: Component { | ||
func render() -> Node { | ||
let handleClick = EventListener { (_) in | ||
do { | ||
try JSWindow.global.alert("You clicked me!") | ||
} catch { | ||
print(error) | ||
} | ||
} | ||
|
||
return button( | ||
listeners: [ | ||
"click": handleClick | ||
] | ||
) { | ||
"Click me" | ||
} | ||
} | ||
} | ||
|
||
try renderRoot(component: MyButton()) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React | ||
import JavaScriptKit | ||
import SRTDOM | ||
import BRTSupport | ||
|
||
// https://ja.react.dev/learn#sharing-data-between-components | ||
|
||
struct MyButton: Component { | ||
var count: Int | ||
var onClick: EventListener | ||
|
||
func render() -> Node { | ||
return button( | ||
listeners: [ | ||
"click": onClick | ||
] | ||
) { | ||
"Clicked \(count) times" | ||
} | ||
} | ||
} | ||
|
||
struct MyApp: Component { | ||
@State var count = 0 | ||
|
||
func render() -> Node { | ||
let handleClick = EventListener { (_) in | ||
count += 1 | ||
} | ||
|
||
return div { | ||
h1 { "Counters that update together" } | ||
MyButton(count: count, onClick: handleClick) | ||
MyButton(count: count, onClick: handleClick) | ||
} | ||
} | ||
} | ||
|
||
try addCSS(path: "/Sources/QSSharing/styles.css") | ||
try renderRoot(component: MyApp()) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
button { | ||
display: block; | ||
margin-bottom: 5px; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React | ||
import JavaScriptKit | ||
import SRTDOM | ||
import BRTSupport | ||
|
||
// https://ja.react.dev/learn#updating-the-screen | ||
|
||
struct MyButton: Component { | ||
@State var count = 0 | ||
|
||
func render() -> Node { | ||
let handleClick = EventListener { (_) in | ||
count += 1 | ||
} | ||
|
||
return button( | ||
listeners: [ | ||
"click": handleClick | ||
] | ||
) { | ||
"Clicked \(count) times" | ||
} | ||
} | ||
} | ||
|
||
struct MyApp: Component { | ||
func render() -> Node { | ||
div { | ||
h1 { "Counters that update separately" } | ||
MyButton() | ||
MyButton() | ||
} | ||
} | ||
} | ||
|
||
try addCSS(path: "/Sources/QSUpdating/styles.css") | ||
try renderRoot(component: MyApp()) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
button { | ||
display: block; | ||
margin-bottom: 5px; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.