-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: hfhbd <[email protected]>
- Loading branch information
Showing
15 changed files
with
357 additions
and
63 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
11 changes: 11 additions & 0 deletions
11
src/jsMain/kotlin/app/softwork/bootstrapcompose/ButtonGroup.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package app.softwork.bootstrapcompose | ||
|
||
import androidx.compose.runtime.* | ||
import org.jetbrains.compose.web.dom.* | ||
|
||
@Composable | ||
public fun ButtonGroup(content: @Composable () -> Unit) { | ||
Div({ classes("btn-group") }) { | ||
content() | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package app.softwork.bootstrapcompose | ||
|
||
import androidx.compose.runtime.* | ||
import org.jetbrains.compose.web.attributes.* | ||
import org.jetbrains.compose.web.dom.* | ||
|
||
@Composable | ||
public fun Card( | ||
header: String, | ||
color: Color = Color.Dark, | ||
attrs: AttrsBuilder<Tag.Div>.() -> Unit = {}, | ||
footer: @Composable () -> Unit = {}, | ||
body: @Composable () -> Unit | ||
) { | ||
Div({ | ||
classes("card", "border-$color", "mb-3") | ||
attrs() | ||
}) { | ||
Div({ classes("card-header") }) { | ||
Text(header) | ||
} | ||
Div({ classes("card-body") }) { | ||
body() | ||
} | ||
Div({ classes("card-footer") }) { | ||
footer() | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/jsMain/kotlin/app/softwork/bootstrapcompose/Checkbox.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package app.softwork.bootstrapcompose | ||
|
||
import androidx.compose.runtime.* | ||
import org.jetbrains.compose.web.attributes.* | ||
import org.jetbrains.compose.web.dom.* | ||
|
||
@Composable | ||
public fun Checkbox(checked: Boolean, label: String, id: String, onClick: () -> Unit) { | ||
Div({ classes("form-check") }) { | ||
Input(attrs = { | ||
classes("form-check-input") | ||
name("flexRadioDefault1") | ||
id("a$id") | ||
checked(checked) | ||
onClick { | ||
onClick() | ||
} | ||
}, type = InputType.Radio) { | ||
} | ||
Label(attrs = { | ||
classes("form-check-label") | ||
forId("a$id") | ||
}) { | ||
Text(label) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/jsMain/kotlin/app/softwork/bootstrapcompose/Collapse.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.softwork.bootstrapcompose | ||
|
||
import androidx.compose.runtime.* | ||
import org.jetbrains.compose.web.attributes.* | ||
import org.jetbrains.compose.web.dom.* | ||
|
||
@Composable | ||
public fun Collapse(title: String, id: String, color: Color = Color.Primary, content: @Composable () -> Unit) { | ||
Button(attrs = { | ||
classes("btn", "btn-$color") | ||
attr("data-bs-toggle", "collapse") | ||
attr("data-bs-target", "#a$id") | ||
attr("aria-expanded", "false") | ||
attr("aria-controls", id) | ||
}, type = ButtonType.Button, title = title) {} | ||
Div({ | ||
classes("collapse") | ||
id("a$id") | ||
}) { | ||
content() | ||
} | ||
} |
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
87 changes: 87 additions & 0 deletions
87
src/jsMain/kotlin/app/softwork/bootstrapcompose/DropDown.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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package app.softwork.bootstrapcompose | ||
|
||
import androidx.compose.runtime.* | ||
import org.jetbrains.compose.web.attributes.* | ||
import org.jetbrains.compose.web.dom.* | ||
|
||
public class DropDownBuilder { | ||
public sealed class Content { | ||
public data class Button(val title: String, val onClick: () -> Unit) : Content() | ||
public data class Header(val title: String) : Content() | ||
public class Custom : Content() { | ||
public lateinit var content: @Composable () -> Unit | ||
} | ||
|
||
public object Divider : Content() | ||
} | ||
|
||
private val content = mutableListOf<Content>() | ||
|
||
public fun Button(title: String, onClick: () -> Unit) { | ||
content.add(Content.Button(title, onClick)) | ||
} | ||
|
||
public fun Divider() { | ||
content.add(Content.Divider) | ||
} | ||
|
||
public fun Header(title: String) { | ||
content.add(Content.Header(title)) | ||
} | ||
|
||
@Composable | ||
public fun Custom(block: @Composable () -> Unit) { | ||
content.add(Content.Custom().apply { content = block }) | ||
} | ||
|
||
internal fun build(): List<Content> = content | ||
} | ||
|
||
@Composable | ||
public fun DropDown(title: String, id: String, color: Color = Color.Primary, block: DropDownBuilder.() -> Unit) { | ||
Div({ classes("dropdown") }) { | ||
val buttons = DropDownBuilder().apply(block).build() | ||
|
||
Button(attrs = { | ||
classes("btn", "btn-$color", "dropdown-toggle") | ||
id("dropdownMenu$id") | ||
attr("data-bs-toggle", "dropdown") | ||
attr("aria-expanded", "false") | ||
}) { | ||
Text(title) | ||
} | ||
|
||
Ul({ | ||
classes("dropdown-menu") | ||
attr("aria-labelledby", "dropdownMenu$id") | ||
}) { | ||
|
||
for (button in buttons) { | ||
Li { | ||
when (button) { | ||
is DropDownBuilder.Content.Button -> { | ||
Button({ | ||
classes("dropdown-item") | ||
onClick { button.onClick() } | ||
}) { | ||
Text(button.title) | ||
} | ||
} | ||
is DropDownBuilder.Content.Divider -> { | ||
Hr({classes("dropdown-divider")}) { | ||
} | ||
} | ||
is DropDownBuilder.Content.Header -> { | ||
H6({classes("dropdown-header")}) { | ||
Text(button.title) | ||
} | ||
} | ||
is DropDownBuilder.Content.Custom -> { | ||
button.content() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/jsMain/kotlin/app/softwork/bootstrapcompose/HorizontalAlignment.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package app.softwork.bootstrapcompose; | ||
|
||
public enum class HorizontalAlignment(private val classInfix: String) { | ||
Start("start"), | ||
Center("center"), | ||
End("end"), | ||
Around("around"), | ||
Between("between"), | ||
Evenly("evenly"); | ||
|
||
override fun toString(): String = "justify-content-$classInfix" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package app.softwork.bootstrapcompose | ||
|
||
import androidx.compose.runtime.* | ||
import org.jetbrains.compose.web.attributes.* | ||
import org.jetbrains.compose.web.dom.* | ||
import org.w3c.dom.* | ||
|
||
public object HrTag : Tag | ||
|
||
// https://github.com/JetBrains/compose-jb/pull/741 | ||
|
||
@Composable | ||
public fun Hr( | ||
attrs: AttrBuilderContext<HrTag> = {}, | ||
content: ContentBuilder<HTMLHRElement>? = null | ||
) { | ||
TagElement("hr", applyAttrs = attrs, content = content) | ||
} |
Oops, something went wrong.