-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent Blankslates from having a zero width inside flex containers (#…
- Loading branch information
Showing
8 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/view-components': patch | ||
--- | ||
|
||
Prevent Blankslates from having a zero width inside flex containers |
This file contains 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
This file contains 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
6 changes: 6 additions & 0 deletions
6
previews/primer/beta/blankslate_preview/inside_flex_container.html.erb
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div style="display: flex"> | ||
<%= render Primer::Beta::Blankslate.new do |component| %> | ||
<% component.with_heading(tag: :h2) { "Heading" } %> | ||
<% component.with_description { "Description" } %> | ||
<% end %> | ||
</div> |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require "system/test_case" | ||
|
||
module Beta | ||
class IntegrationBlankslateTest < System::TestCase | ||
include Primer::JsTestHelpers | ||
|
||
def test_has_a_width_when_inside_a_flex_container | ||
visit_preview(:inside_flex_container) | ||
|
||
info = evaluate_multiline_script(<<~JS) | ||
const style = window.getComputedStyle(document.querySelector('.blankslate')); | ||
return { | ||
width: style.getPropertyValue('width'), | ||
padding: style.getPropertyValue('padding') | ||
} | ||
JS | ||
|
||
width = info["width"].to_i | ||
padding = info["padding"].to_i | ||
calc_width = width - (padding * 2) | ||
|
||
assert calc_width > 0, "Blankslate appears to have zero width" | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module JsTestHelpers | ||
def evaluate_multiline_script(script) | ||
page.evaluate_script(<<~JS) | ||
(() => { #{script} })() | ||
JS | ||
end | ||
end | ||
end |