-
Notifications
You must be signed in to change notification settings - Fork 60
Support the @Row
directive
#409
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 the @Row
directive
#409
Conversation
One thing I am not sure I like is the naming. We already have |
I agree it's a little annoying but also not a huge deal, especially since these are located within the |
Co-authored-by: Marcus Ortiz <[email protected]>
…com/dobromir-hristov/swift-docc-render into dhristov/r97715742-add-grid-support
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.
I was actually thinking about that the other day. We dont add any gutter to our GridRow and GridColumn, but those are building blocks, so it makes sense. Here however, I think as users wont have the possibility to add those, we should have nice defaults. I will make it configurable via a prop, with some sensible defaults. |
Hey @mportiz08 I added the gap and all, but I am not sure if I like how the grid works when no column count is provided, aka auto mode. Should we ensure we always fit up to a max of 12 columns, no matter how small they are, or do we add some sensible default? This is something I saw thrown around on comment sections that is pretty clever. We can specify a max number of columns, the gap and the minimum size a column should be, and it should fit as many columns as it can, up to that 12 in general is probably too much but yeah... grid-template-columns: repeat(auto-fit, minmax(
min(
max(
100% / var(--col-count) - var(--gap),
var(--min-col-size)
),
100%
),
1fr
)); |
The gap is looking good to me visually now, thanks!
I may be misunderstanding, but I don't think so. For example, I would expect the following to result in a grid with only 2 columns which are evenly spaced half/half, taking up the full width of the content area: @Row {
@Column {
Foo
}
@Column {
Bar
}
} I think the concept of an "N column" grid only applies when both a For example, if someone wanted to create a row a very small first and last column and a big middle column: @Row(numberOfColumns: 12) {
@Column(size: 1) {
Foo
}
@Column {
Bar
}
@Column(size: 1) {
Baz
}
} That's just based on the way I interpreted the proposal at Supporting more dynamic content in Swift-DocC reference documentation though, so @ethan-kusters please correct me if I misunderstand or I'm missing anything. It's also just possible that you were asking if we should impose a maximum number of columns, but I'm also not sure about that. I don't think so, because maybe it would be reasonable to specify a 100 numCols with only 2 columns and one of them specifying size 5 to basically allow for a 5% width type of thing...maybe that's too much flexibility though and we want to enforce a 12 max—I'll need @ethan-kusters to give his thoughts there.
Going to take your word for it that the syntax is right there—the grid templating styles are so complex, haha. Sounds like an interesting idea as long as it plays nicely with what is allowed in the new markdown directive and its allowed argument values. |
How do you imagine the prop could be modified? Would that be intended as a possible future theme setting? |
I thought that it might be pretty easy for both Content Authors and DoccRender Developers using the I actually needed this for #419 but I think the default we added now is good enough for that use case. |
Almost... What you explained is exactly how it works now. But what if you add more columns in your scenario? How should it behave? Should it limit you to a max of 12 and wrap? Or should we limit to a @SamLanier and @ethan-kusters I need your input on this, so I can wrap up the styling.
|
We do not want to limit the authoring of columns. Yes, this means authors can create some not-so-great layouts, but it should be up to the author (or authoring guidelines) to create the best experience for the content. |
@swift-ci test |
OK I have refactored this to not have limits anymore. |
@swift-ci test |
Adds support for the @Row and @column directive as described here: https://forums.swift.org/t/supporting-more-dynamic-content-in-swift-docc-reference-documentation/59527#row-9. Dependencies: - swiftlang/swift-docc-render#409 Example: @Row(numberOfColumns: 3) { @column(size: 1) {  } @column(size: 2) { SlothCreator provides models and utilities for creating, tracking, and caring for sloths. The framework provides structures to model an individual ``Sloth``, and identify them by key characteristics, including their ``name`` and special supernatural ``power``. } } Resolves rdar://97739637
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.
I tested different use cases and it works great :)
I left minor comments
.column { | ||
grid-column: span var(--col-span); | ||
min-width: 0; |
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.
Why is min-width: 0;
needed?
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.
Tells the flex/column item to become smaller than it can right now, so it does not overflow.
If we have images or text that are wider than the column, this will make the column outgrow what it should.
required: false, | ||
validator: v => v > 0, | ||
}, | ||
gap: { |
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.
Are we using this prop at the moment?
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.
Not right now, but I am assuming we may start to, if we start using this as a building block for future components.
# Conflicts: # src/components/ContentNode.vue # tests/unit/components/ContentNode.spec.js
# Conflicts: # src/components/ContentNode.vue # tests/unit/components/ContentNode.spec.js
@swift-ci test |
Bug/issue #, if applicable: 97715742
Summary
This PR adds support for the new
@Row
directive in DocC.Dependencies
DocC PR - swiftlang/swift-docc#378
Testing
Use the provided JSON file or insert the snippet below:
Steps:
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
npm test
, and it succeeded