Skip to content

Commit

Permalink
Utility classes for media and row (#1213)
Browse files Browse the repository at this point in the history
Utility classes for media and row
  • Loading branch information
ptbrowne authored Oct 22, 2019
2 parents 69fe801 + 9187f75 commit 7ef45de
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11 deletions.
5 changes: 3 additions & 2 deletions react/Media/Media.md → react/Media/Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
The mighty Media object. Also known as Flag. Used to align vertically
objects.
The mighty Media object. Also known as Flag. Used to horizontally align
objects. Utility classes are also available and are preferred since they
prevent nesting.

* `<Bd />` tries to take the space available
* `<Img />` is as small as possible
Expand Down
15 changes: 7 additions & 8 deletions react/Media/styles.styl
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
@require '../../stylus/objects/media'

.media
display flex
align-items center
@extend $media

.media--top
align-items flex-start
@extend $media--top

.media--bottom
align-items flex-end
@extend $media--bottom

.bd
flex 1 1 auto
overflow hidden
@extend $media__grow

.img
line-height 0
flex 0 0 auto
@extend $media__fixed
27 changes: 27 additions & 0 deletions react/__snapshots__/examples.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3321,6 +3321,33 @@ exports[`ListItemText should render examples: ListItemText 3`] = `
</div>"
`;
exports[`Media should render examples: Media 1`] = `
"<div>
<div class=\\"styles__media___cSJMp\\">
<div class=\\"styles__img___3SHpG\\"><img src=\\"http://lorempixel.com/90/90/people\\" style=\\"margin-right: 1rem;\\"></div>
<div class=\\"styles__bd___1Uv-F\\">Augusta Ada King-Noel, Countess of Lovelace (née Byron; 10 December 1815 27 November 1852) was an English mathematician and writer, chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer, the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation, and published the first algorithm intended to be carried out by such a machine. As a result, she is often regarded as the first to recognise the full potential of a \\"computing machine\\" and the first computer programmer.</div>
</div>
</div>"
`;
exports[`Media should render examples: Media 2`] = `
"<div>
<div class=\\"styles__media___cSJMp styles__media--top___K9w0I\\">
<div class=\\"styles__img___3SHpG\\"><img src=\\"http://lorempixel.com/90/90/people\\" style=\\"margin-right: 1rem;\\"></div>
<div class=\\"styles__bd___1Uv-F\\">Augusta Ada King-Noel, Countess of Lovelace (née Byron; 10 December 1815 27 November 1852) was an English mathematician and writer, chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer, the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation, and published the first algorithm intended to be carried out by such a machine. As a result, she is often regarded as the first to recognise the full potential of a \\"computing machine\\" and the first computer programmer.</div>
</div>
</div>"
`;
exports[`Media should render examples: Media 3`] = `
"<div>
<div class=\\"styles__media___cSJMp styles__media--bottom___21YWJ\\">
<div class=\\"styles__img___3SHpG\\"><img src=\\"http://lorempixel.com/90/90/people\\" style=\\"margin-right: 1rem;\\"></div>
<div class=\\"styles__bd___1Uv-F\\">Augusta Ada King-Noel, Countess of Lovelace (née Byron; 10 December 1815 27 November 1852) was an English mathematician and writer, chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer, the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation, and published the first algorithm intended to be carried out by such a machine. As a result, she is often regarded as the first to recognise the full potential of a \\"computing machine\\" and the first computer programmer.</div>
</div>
</div>"
`;
exports[`Menu should render examples: Menu 1`] = `
"<div>
<div class=\\"styles__c-menu___2YTiU styles__c-menu--left___3wamY\\" id=\\"menu\\"><button role=\\"button\\" class=\\"c-btn styles__c-menu__btn___18qF8\\">Click me !</button>
Expand Down
1 change: 1 addition & 0 deletions react/examples.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ testComponent('InlineCard')
testComponent('InputGroup')
testComponent('Label')
testComponent('ListItemText')
testComponent('Media')
testComponent('Menu')
testComponent('Radio')
testComponent('SelectBox')
Expand Down
17 changes: 17 additions & 0 deletions stylus/objects/media.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$media
display flex
align-items center

$media--top
align-items flex-start

$media--bottom
align-items flex-end

$media__grow
flex 1 1 auto
overflow hidden

$media__fixed
line-height 0
flex 0 0 auto
8 changes: 8 additions & 0 deletions stylus/utilities/media.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@require '../tools/mixins'
@require '../objects/media'

global('.u-media', $media)
global('.u-media-top', $media--top)
global('.u-media-bottom', $media--bottom)
global('.u-media-grow', $media__grow)
global('.u-media-fixed', $media__fixed)
2 changes: 1 addition & 1 deletion stylus/utilities/spaces.styl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ sizes = {
// These are the values used by the design team, they should used
// instead of the `sizes` variable above that is only kept for retro-compatibility
spacing_values = {
m: 1rem, // the standard, no modifier needed
xs: .5rem,
s: .75rem,
m: 1rem, // the standard, no modifier needed
l: 1.5rem,
xl: 2rem
xxl: 3rem
Expand Down
9 changes: 9 additions & 0 deletions stylus/utilities/stack.styl
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ else
for k, v in spacing_values
.u-stack-{k} > * + *
margin-top v[0]

if cssmodules == true
for k, v in spacing_values
:global(.u-row-{k} > * + *)
margin-left v[0]
else
for k, v in spacing_values
.u-row-{k} > * + *
margin-left v[0]

0 comments on commit 7ef45de

Please sign in to comment.