-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[DREAM-693] Unify and document ExpandableTextComponent
#23328
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4477b8c
[#75274] Unify truncation controllers
myabc 17dec9f
[#75274] Compose from AttributeComponent
myabc da299b9
[#75274] Add and document ExpandableText preview
myabc 7f03c9c
[#75274] Extract VerticalTruncateComponent
myabc b08309d
Privatise expandable-text controller; rename API
myabc 78e0b9e
Deep-dup expander_arguments to protect caller hashes
myabc ba70cd6
Add VerticalTruncateComponent Lookbook preview
myabc d06192e
Merge branch 'dev' into code-maintenance/75274-document-expandable-text
myabc 8a016f5
Own the dialog slot in ExpandableText
myabc ec5558b
[DREAM-693] Rework the ExpandableText docs
myabc 0f8f839
Merge branch 'dev' into code-maintenance/75274-document-expandable-text
myabc 6a89622
Expose dialog ARIA on the ExpandableText expander
myabc 7034c07
Disable preview cop for VerticalTruncateComponent
myabc 1a92b29
Use accessible selectors in ExpandableText spec
myabc 0915bc7
Increase height of vertical preview
myabc 09e58d3
Extract ExpandableText lines default to a constant
myabc 2bd9d11
Fix broken Lookbook preview link in ExpandableText docs
myabc 9b47949
Rename ExpandableText direction to truncate
myabc a957c67
Bump ExpandableText line clamp limit to 8
myabc 852b075
Floor multi_line truncation at 2 lines
myabc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 17 additions & 11 deletions
28
app/components/op_primer/expandable_text_component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,21 @@ | ||
| <%= render(Primer::BaseComponent.new(**@system_arguments)) do %> | ||
| <%= render Primer::Beta::Truncate.new( | ||
| data: { truncation_target: "truncate" }, | ||
| flex: 1 | ||
| ) do %> | ||
| <%= content %> | ||
| <% if truncation.vertical? %> | ||
| <%= render Primer::BaseComponent.new( | ||
| tag: :div, | ||
| flex: 1, | ||
| classes: "line-clamp-#{lines} min-width-0", | ||
| data: { truncation_target: "truncate" } | ||
| ) do %> | ||
| <%= content %> | ||
| <% end %> | ||
| <% else %> | ||
| <%= render Primer::Beta::Truncate.new( | ||
| flex: 1, | ||
| data: { truncation_target: "truncate" } | ||
| ) do %> | ||
| <%= content %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= render Primer::Alpha::HiddenTextExpander.new( | ||
| hidden: true, | ||
| mt: 1, | ||
| aria: { label: t(:"js.label_expand_text") }, | ||
| data: { truncation_target: "expander" } | ||
| ) %> | ||
| <%= render Primer::Alpha::HiddenTextExpander.new(**expander_arguments) %> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 29 additions & 53 deletions
82
app/components/open_project/common/attribute_component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,30 @@ | ||
| <div | ||
| data-controller="attribute" | ||
| data-attribute-background-reference-id-value="<%= background_reference_id %>" | ||
| class="op-long-text-attribute"> | ||
| <%= render( | ||
| OpPrimer::ExpandableTextComponent.new( | ||
| truncation: truncation_direction, | ||
| lines:, | ||
| inline: false, | ||
| expander_arguments: { | ||
| hidden: !show_expander?, | ||
| aria: { label: I18n.t("label_attribute_expand_text", attribute: name) }, | ||
| button_arguments: { data: { show_dialog_id: id } }, | ||
| test_selector: "expand-button" | ||
| } | ||
| ) | ||
| ) do | ||
| render( | ||
| Primer::Beta::Text.new(classes: PARAGRAPH_CSS_CLASS, color: text_color) | ||
| .with_content(short_text) | ||
| ) | ||
| end %> | ||
|
|
||
| <%= render( | ||
| Primer::Beta::Text.new( | ||
| tag: :div, | ||
| classes: ["op-long-text-attribute--text", PARAGRAPH_CSS_CLASS], | ||
| color: text_color, | ||
| style: "max-height: #{max_height};", | ||
| data: { | ||
| "attribute-target": "descriptionText" | ||
| } | ||
| ) | ||
| ) { short_text } %> | ||
|
|
||
| <%= render( | ||
| Primer::Beta::Text.new( | ||
| tag: :div, | ||
| display: display_expand_button_value, | ||
| classes: "op-long-text-attribute--text-hider", | ||
| data: { "attribute-target": "textHider" } | ||
| ) | ||
| ) %> | ||
|
|
||
| <%= render( | ||
| Primer::Alpha::HiddenTextExpander.new( | ||
| inline: false, | ||
| "aria-label": I18n.t("label_attribute_expand_text", attribute: name), | ||
| display: display_expand_button_value, | ||
| data: { | ||
| "attribute-target": "expandButton", | ||
| "test-selector": "expand-button" | ||
| }, | ||
| button_arguments: { "data-show-dialog-id": id }, | ||
| classes: "op-long-text-attribute--text-expander" | ||
| ) | ||
| ) %> | ||
|
|
||
| <%= render( | ||
| Primer::Alpha::Dialog.new( | ||
| id: id, | ||
| data: { | ||
| "test-selector": "attribute-dialog" | ||
| }, | ||
| title: name, | ||
| size: :large | ||
| ) | ||
| ) do |component| | ||
| component.with_body { full_text } | ||
| component.with_header(variant: :large) | ||
| end %> | ||
| </div> | ||
| <%= render( | ||
| Primer::Alpha::Dialog.new( | ||
| id: id, | ||
| title: name, | ||
| size: :large, | ||
| test_selector: "attribute-dialog" | ||
| ) | ||
| ) do |component| | ||
| component.with_body_content(full_text) | ||
| component.with_header(variant: :large) | ||
| end %> | ||
|
myabc marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
app/components/open_project/common/attribute_component.sass
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| @for $i from 1 through 6 | ||
| .line-clamp-#{$i} | ||
| @include line-clamp($i) | ||
|
|
||
| .expandable-text--expanded | ||
| // display: block makes -webkit-box-orient inert, so no need to reset it here | ||
| -webkit-line-clamp: unset !important | ||
| display: block !important | ||
| overflow: visible !important |
84 changes: 0 additions & 84 deletions
84
frontend/src/stimulus/controllers/dynamic/attribute.controller.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.