Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RTL layout direction in redwood-layout-dom #1509

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ private class HTMLFlexContainer(

override fun margin(margin: Margin) {
value.style.apply {
marginLeft = margin.start.toPxString()
marginRight = margin.end.toPxString()
marginInlineStart = margin.start.toPxString()
marginInlineEnd = margin.end.toPxString()
marginTop = margin.top.toPxString()
marginBottom = margin.bottom.toPxString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import app.cash.redwood.layout.api.Overflow
import app.cash.redwood.ui.Density
import app.cash.redwood.ui.Dp
import kotlin.math.roundToInt
import org.w3c.dom.css.CSSStyleDeclaration

internal fun Dp.toPxString(): String = with(Density(1.0)) {
"${toPx().roundToInt()}px"
Expand Down Expand Up @@ -56,3 +57,15 @@ internal fun Overflow.toCss() = when (this) {
Overflow.Scroll -> "scroll"
else -> throw AssertionError()
}

internal var CSSStyleDeclaration.marginInlineStart: String
get() = this.getPropertyValue("margin-inline-start")
set(value) {
this.setProperty("margin-inline-start", value)
}

internal var CSSStyleDeclaration.marginInlineEnd: String
get() = this.getPropertyValue("margin-inline-end")
set(value) {
this.setProperty("margin-inline-end", value)
}