-
Notifications
You must be signed in to change notification settings - Fork 13
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
Validate panel grid arrangement in layout editor #351
base: main
Are you sure you want to change the base?
Conversation
|
||
object LayoutValidatorSpec : Spek({ | ||
describe<LayoutValidator> { | ||
val layoutValidator by value { LayoutValidator() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This by value
thing creates a new instance for every spec — for each it
block.
object LayoutValidatorSpec : Spek({ | ||
describe<LayoutValidator> { | ||
val layoutValidator by value { LayoutValidator() } | ||
val tab by value<Tab> { toBeSpecified() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also useoverride
to change the value in nested contexts, see below.
val invalidRegions by value { layoutValidator.findInvalidRegions(tab) } | ||
|
||
context("when all regions are single cells") { | ||
override(tab) { tab(3, 3, "ABC DEF GHI") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it behave as though line 14 had this value the whole time, within this context
.
} | ||
}) | ||
|
||
fun tab(columns: Int, rows: Int, areas: String): Tab { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helper method to convert "aa bb" to a Tab
with ["a", "a", "b", "b"].
Multi-cell panels in the grid must follow CSS Grid rules: they must be rectangular and contiguous.
If the arrangement is invalid, show that there's an error, maybe indicate which panels are invalid, and refuse to apply the change.