-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from InkApplications/static-html
Static HTML layouts and formatted text
- Loading branch information
Showing
82 changed files
with
718 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 19 additions & 26 deletions
45
render-compose-html/src/jsMain/kotlin/ink/ui/render/compose/html/renderer/ButtonRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,30 @@ | ||
package ink.ui.render.compose.html.renderer | ||
|
||
import androidx.compose.runtime.Composable | ||
import ink.ui.render.web.svgSrc | ||
import ink.ui.render.web.toCssClass | ||
import ink.ui.structures.elements.ButtonElement | ||
import ink.ui.structures.elements.UiElement | ||
import org.jetbrains.compose.web.dom.Button | ||
import org.jetbrains.compose.web.dom.Img | ||
import org.jetbrains.compose.web.dom.Text | ||
|
||
object ButtonRenderer: ElementRenderer { | ||
@Composable | ||
override fun render(element: UiElement, parent: ElementRenderer): RenderResult { | ||
if (element !is ButtonElement) return RenderResult.NotRendered | ||
|
||
Button( | ||
attrs = { | ||
classes(element.sentiment.toCssClass()) | ||
onClick { | ||
element.onClick() | ||
} | ||
} | ||
) { | ||
val leadingSymbol = element.leadingSymbol | ||
if (leadingSymbol != null) { | ||
Img( | ||
attrs = { | ||
classes("icon", "svg-fill", element.sentiment.toCssClass()) | ||
}, | ||
src = leadingSymbol.svgSrc, | ||
) | ||
val ButtonRenderer = renderer<ButtonElement> { element -> | ||
Button( | ||
attrs = { | ||
classes(element.sentiment.toCssClass()) | ||
onClick { | ||
element.onClick() | ||
} | ||
Text(element.text) | ||
} | ||
|
||
return RenderResult.Rendered | ||
) { | ||
val leadingSymbol = element.leadingSymbol | ||
if (leadingSymbol != null) { | ||
Img( | ||
attrs = { | ||
classes("icon", "svg-fill", element.sentiment.toCssClass()) | ||
}, | ||
src = leadingSymbol.svgSrc, | ||
) | ||
} | ||
Text(element.text) | ||
} | ||
} |
25 changes: 8 additions & 17 deletions
25
...er-compose-html/src/jsMain/kotlin/ink/ui/render/compose/html/renderer/CheckBoxRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
package ink.ui.render.compose.html.renderer | ||
|
||
import androidx.compose.runtime.Composable | ||
import ink.ui.structures.elements.CheckBoxElement | ||
import ink.ui.structures.elements.UiElement | ||
import org.jetbrains.compose.web.attributes.InputType | ||
import org.jetbrains.compose.web.dom.Input | ||
|
||
object CheckBoxRenderer: ElementRenderer { | ||
@Composable | ||
override fun render(element: UiElement, parent: ElementRenderer): RenderResult { | ||
if (element !is CheckBoxElement) return RenderResult.NotRendered | ||
|
||
Input( | ||
type = InputType.Checkbox, | ||
attrs = { | ||
onClick { element.onClick() } | ||
checked(element.checked) | ||
} | ||
) | ||
|
||
return RenderResult.Rendered | ||
} | ||
val CheckBoxRenderer = renderer<CheckBoxElement> { element -> | ||
Input( | ||
type = InputType.Checkbox, | ||
attrs = { | ||
onClick { element.onClick() } | ||
checked(element.checked) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 1 addition & 10 deletions
11
render-compose-html/src/jsMain/kotlin/ink/ui/render/compose/html/renderer/EmptyRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
package ink.ui.render.compose.html.renderer | ||
|
||
import androidx.compose.runtime.Composable | ||
import ink.ui.structures.elements.EmptyElement | ||
import ink.ui.structures.elements.UiElement | ||
import org.jetbrains.compose.web.dom.Span | ||
|
||
object EmptyRenderer: ElementRenderer { | ||
@Composable | ||
override fun render(element: UiElement, parent: ElementRenderer): RenderResult { | ||
if (element !is EmptyElement) return RenderResult.NotRendered | ||
|
||
val EmptyRenderer = renderer<EmptyElement> { element -> | ||
Span {} | ||
|
||
return RenderResult.Rendered | ||
} | ||
} |
25 changes: 9 additions & 16 deletions
25
render-compose-html/src/jsMain/kotlin/ink/ui/render/compose/html/renderer/IconRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
package ink.ui.render.compose.html.renderer | ||
|
||
import androidx.compose.runtime.Composable | ||
import ink.ui.render.web.svgSrc | ||
import ink.ui.render.web.toCssClass | ||
import ink.ui.structures.elements.IconElement | ||
import ink.ui.structures.elements.UiElement | ||
import org.jetbrains.compose.web.dom.Img | ||
|
||
object IconRenderer: ElementRenderer { | ||
@Composable | ||
override fun render(element: UiElement, parent: ElementRenderer): RenderResult { | ||
if (element !is IconElement) return RenderResult.NotRendered | ||
|
||
Img( | ||
src = element.symbol.svgSrc, | ||
attrs = { | ||
classes("icon", "svg-fill", element.sentiment.toCssClass()) | ||
} | ||
) | ||
|
||
return RenderResult.Rendered | ||
} | ||
val IconRenderer = renderer<IconElement> { element -> | ||
Img( | ||
src = element.symbol.svgSrc, | ||
attrs = { | ||
classes("icon", "svg-fill", element.sentiment.toCssClass()) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
render-compose-html/src/jsMain/kotlin/ink/ui/render/compose/html/renderer/RenderResult.kt
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
render-compose-html/src/jsMain/kotlin/ink/ui/render/compose/html/renderer/Sentiments.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.