Skip to content

Commit

Permalink
Remove default .row and .column default gap value, default now to null
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Jun 23, 2024
1 parent 9a222c3 commit 0e85d48
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data class Stacked(
val orientation: Orientation,
val mainAxisAlignment: MainAxisAlignment,
val crossAxisAlignment: CrossAxisAlignment,
val gap: Size,
val gap: Size?,
override val children: List<Node>,
) : NestableNode {
override fun <T> accept(visitor: NodeVisitor<T>) = visitor.visit(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CssBuilder {
private val entries = mutableMapOf<String, String>()

/**
* Pushes a key-value CSS entry.
* Pushes a key-value CSS entry as long as [value] is not `null`.
* @param key CSS entry key
* @param value CSS entry value
* @return this for concatenation
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/render/theme/layout/plain.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.stacked {
gap: 12px;
}

/* Slides */

h1, h2, h3, h4, h5, h6 {
Expand Down
Empty file modified gradlew
100755 → 100644
Empty file.
21 changes: 6 additions & 15 deletions stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/Layout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import eu.iamgio.quarkdown.ast.Stacked
import eu.iamgio.quarkdown.ast.Table
import eu.iamgio.quarkdown.context.Context
import eu.iamgio.quarkdown.document.page.Size
import eu.iamgio.quarkdown.document.page.SizeUnit
import eu.iamgio.quarkdown.function.reflect.Injected
import eu.iamgio.quarkdown.function.reflect.Name
import eu.iamgio.quarkdown.function.value.NodeValue
Expand Down Expand Up @@ -52,20 +51,12 @@ fun align(
*/
fun center(body: MarkdownContent) = align(Aligned.Alignment.CENTER, body)

/**
* Default gap between stacked contents.
* @see stack
* @see row
* @see column
*/
private val DEFAULT_STACK_GAP = Size(12.0, SizeUnit.PX)

/**
* Stacks content along an axis.
* @param orientation orientation of the stack
* @param mainAxisAlignment content alignment along the main axis
* @param crossAxisAlignment content alignment along the cross axis
* @param gap blank space between children
* @param gap blank space between children. If omitted, the default value is used
* @param body content to stack
* @return the new stacked block
* @see row
Expand All @@ -75,39 +66,39 @@ fun stack(
orientation: Stacked.Orientation,
@Name("alignment") mainAxisAlignment: Stacked.MainAxisAlignment = Stacked.MainAxisAlignment.START,
@Name("cross") crossAxisAlignment: Stacked.CrossAxisAlignment = Stacked.CrossAxisAlignment.CENTER,
gap: Size = DEFAULT_STACK_GAP,
gap: Size? = null,
body: MarkdownContent,
) = Stacked(orientation, mainAxisAlignment, crossAxisAlignment, gap, body.children).wrappedAsValue()

/**
* Stacks content horizontally.
* @param mainAxisAlignment content alignment along the main axis
* @param crossAxisAlignment content alignment along the cross axis
* @param gap blank space between children
* @param gap blank space between children. If omitted, the default value is used
* @param body content to stack
* @return the new stacked block
* @see stack
*/
fun row(
@Name("alignment") mainAxisAlignment: Stacked.MainAxisAlignment = Stacked.MainAxisAlignment.START,
@Name("cross") crossAxisAlignment: Stacked.CrossAxisAlignment = Stacked.CrossAxisAlignment.CENTER,
gap: Size = DEFAULT_STACK_GAP,
gap: Size? = null,
body: MarkdownContent,
) = stack(Stacked.Orientation.HORIZONTAL, mainAxisAlignment, crossAxisAlignment, gap, body)

/**
* Stacks content vertically.
* @param mainAxisAlignment content alignment along the main axis
* @param crossAxisAlignment content alignment along the cross axis
* @param gap blank space between children
* @param gap blank space between children. If omitted, the default value is used
* @param body content to stack
* @return the new stacked block
* @see stack
*/
fun column(
@Name("alignment") mainAxisAlignment: Stacked.MainAxisAlignment = Stacked.MainAxisAlignment.START,
@Name("cross") crossAxisAlignment: Stacked.CrossAxisAlignment = Stacked.CrossAxisAlignment.CENTER,
gap: Size = DEFAULT_STACK_GAP,
gap: Size? = null,
body: MarkdownContent,
) = stack(Stacked.Orientation.VERTICAL, mainAxisAlignment, crossAxisAlignment, gap, body)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class FullPipelineTest {
""".trimIndent(),
) {
assertEquals(
"<div class=\"stack stack-horizontal\" style=\"justify-content: flex-start; align-items: center; gap: 12.0px;\">" +
"<div class=\"stack stack-horizontal\" style=\"justify-content: flex-start; align-items: center;\">" +
"<p>Hello 1\nHello 2</p><p>Hello 3</p>" +
"</div>",
it,
Expand Down Expand Up @@ -273,7 +273,7 @@ class FullPipelineTest {
) {
assertEquals(
"<div class=\"stack stack-horizontal\" style=\"justify-content: center; align-items: center; gap: 200.0px;\">" +
"<div class=\"stack stack-vertical\" style=\"justify-content: flex-start; align-items: flex-end; gap: 12.0px;\">" +
"<div class=\"stack stack-vertical\" style=\"justify-content: flex-start; align-items: flex-end;\">" +
"<h1>Quarkdown</h1><p>A cool language</p>" +
"</div>" +
"<div class=\"stack stack-vertical\" style=\"justify-content: flex-start; align-items: center; gap: 1.0cm;\">" +
Expand Down

0 comments on commit 0e85d48

Please sign in to comment.