Skip to content

Instantly share code, notes, and snippets.

@cameronhunter
Last active August 27, 2015 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronhunter/7e9a2316655eac536496 to your computer and use it in GitHub Desktop.
Save cameronhunter/7e9a2316655eac536496 to your computer and use it in GitHub Desktop.
/**
* Identity
*
* 1. Ensure that the parent container has a max-width of 0 to
* guarantee correct text-overflow behavior in small widths.
*/
:root {
--Identity-avatar-size: 32px;
}
.Identity {
display: flex;
min-width: inherit; /* 1 */
}
.Identity-avatar {
flex-shrink: 0;
width: var(--Identity-avatar-size);
}
.Identity-details {
display: flex;
flex-wrap: wrap;
min-width: inherit;
flex-grow: 1;
align-items: center;
}
/**
* QuoteTweet
*
* A tweet template that is horizontal when space is available and collapses
* to a vertical stack when horizontal space is limited.
*
* 1. Flex items won't shrink below their minimum content size. To change this
* we set the min width to 0.
*/
:root {
--QuoteTweet-minWidth: 150px;
}
.QuoteTweet {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: flex-start;
min-width: var(--QuoteTweet-minWidth);
}
.QuoteTweet-details {
display: flex;
align-items: center;
flex-basis: 100%;
}
.QuoteTweet-identity {
flex-grow: 1;
min-width: 0; /* 1 */
}
.QuoteTweet-media {
min-width: inherit;
flex-basis: 50%;
flex-grow: 1;
}
.QuoteTweet-text {
word-break: break-word;
flex-basis: 50%;
flex-grow: 1;
}
<div style="max-width: 350px">
<div class="QuoteTweet">
<div class="QuoteTweet-details">
<div class="QuoteTweet-identity">
<div class="Identity">
<div class="Identity-avatar">
<img class="u-sizeFull" src="https://pbs.twimg.com/profile_images/438402304840974336/ExlEDxK7.jpeg" />
</div>
<div class="Identity-details">
<span class="Identity-name u-overflowEllipsis">Cameron Hunter</span>
<span class="Identity-username u-overflowEllipsis">@cameronhunter</span>
</div>
</div>
</div>
<span class="QuoteTweet-timestamp">17h</span>
</div>
<div class="QuoteTweet-media">
<img class="u-sizeFull" src="https://pbs.twimg.com/media/CMV66nSUsAAXQSa.jpg" />
</div>
<div class="QuoteTweet-text">
Impromptu endurance karting is HARD but FUN — with @dwjr, @natbolton, and @necolas
</div>
</div>
</div>
.u-overflowEllipsis {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.u-sizeFull {
box-sizing: border-box !important;
display: block !important;
width: 100% !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment