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

Validate panel grid arrangement in layout editor #351

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xian
Copy link
Member

@xian xian commented Feb 20, 2021

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.


object LayoutValidatorSpec : Spek({
describe<LayoutValidator> {
val layoutValidator by value { LayoutValidator() }
Copy link
Member Author

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() }
Copy link
Member Author

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") }
Copy link
Member Author

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 {
Copy link
Member Author

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"].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant