This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copy button, text, and card (#437)
* Add copy button, text, and card * Update to allow semibold as an option * Remove semibold modifier on button * Update documentation
- Loading branch information
1 parent
90cb7b5
commit a96f87d
Showing
15 changed files
with
135 additions
and
0 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
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,12 @@ | ||
<h5>Copy Text (inline)</h5> | ||
<%= sage_component SageCopyText, { value: "me.ns.cloudflare.com", semibold: true } %> | ||
|
||
<h5>Copy Text (block)</h5> | ||
<%= sage_component SageCopyTextCard, {} do %> | ||
<p><b>Reply:</b> me.ns.cloudflare.com</p> | ||
<p>me.ns.cloudflare.com</p> | ||
<p>me.ns.cloudflare.com</p> | ||
<% end %> | ||
|
||
<h5>Copy Button</h5> | ||
<%= sage_component SageCopyButton, { value: "me.ns.cloudflare.com", semibold: true } %> |
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 @@ | ||
<tr> | ||
<td>semibold</td> | ||
<td>Wether or not the whole block should be set at the Semibold weight, since a number of implementations use this.</td> | ||
<td>Boolean</td> | ||
<td>false</td> | ||
</tr> |
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,4 @@ | ||
<ul> | ||
<li>Use inline <code><b></code> tag to add bolding to select portions of these blocks.</li> | ||
<li>Provide a local max-width as desired in order to limit overflowing text. Truncation is setup and ready for this.</li> | ||
</ul> |
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,3 @@ | ||
<ul> | ||
<li>Manually apply bolding to an entire block of any of these components; use <code>semibold</code> prop to accomplish this effect instead.</li> | ||
</ul> |
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
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
71 changes: 71 additions & 0 deletions
71
lib/sage-frontend/stylesheets/system/patterns/elements/_copy_text.scss
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,71 @@ | ||
/* ================================================== | ||
** copy_text | ||
type: element | ||
================================================== */ | ||
|
||
$-copy-text-border: 1px solid sage-color(grey, 400); | ||
$-copy-text-color: sage-color(charcoal, 400); | ||
$-copy-text-color-hover: sage-color(charcoal, 500); | ||
|
||
@mixin sage-copy-text() { | ||
@extend %t-sage-body-small; | ||
|
||
@include truncate(); | ||
|
||
color: sage-color(charcoal, 400); | ||
background-color: sage-color(grey, 200); | ||
border: $-copy-text-border; | ||
border-radius: sage-border(radius); | ||
} | ||
|
||
.sage-copy-text { | ||
@include sage-copy-text; | ||
|
||
display: inline-block; | ||
padding: 0 sage-spacing(xs); | ||
|
||
.sage-copy-btn & { | ||
transition: $sage-transition; | ||
transition-property: color, background-color; | ||
} | ||
|
||
.sage-copy-btn:hover & { | ||
color: $-copy-text-color-hover; | ||
background-color: sage-color(grey, 100); | ||
border-color: sage-color(grey, 500); | ||
} | ||
} | ||
|
||
.sage-copy-text-card { | ||
@include sage-grid-stack; | ||
@include sage-copy-text; | ||
|
||
padding: $sage-card-padding; | ||
} | ||
|
||
.sage-copy-btn { | ||
@include sage-button-style-reset(); | ||
@include sage-focus-outline($-copy-text-color-hover); | ||
|
||
display: inline-flex; | ||
flex-flow: row-reverse; | ||
align-items: center; | ||
padding-right: sage-spacing(2xs); | ||
|
||
&::before { | ||
@include sage-icon-base(copy); | ||
|
||
margin-left: sage-spacing(xs); | ||
color: $-copy-text-color; | ||
} | ||
|
||
&:hover::before { | ||
color: $-copy-text-color-hover; | ||
} | ||
} | ||
|
||
.sage-copy-text--semibold, | ||
.sage-copy-text-card--semibold { | ||
@extend %t-sage-body-small-semi; | ||
} |
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,4 @@ | ||
class SageCopyButton < SageComponent | ||
attr_accessor :value | ||
attr_accessor :semibold | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class SageCopyText < SageComponent | ||
attr_accessor :value | ||
attr_accessor :semibold | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class SageCopyTextCard < SageComponent | ||
attr_accessor :semibold | ||
end |
6 changes: 6 additions & 0 deletions
6
lib/sage_rails/app/views/sage_components/_sage_copy_button.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 @@ | ||
<button | ||
class="sage-copy-btn" | ||
data-js-copy-button="<%= component.value.html_safe %>" | ||
> | ||
<%= sage_component SageCopyText, { value: component.value, semibold: component.semibold.present? && component.semibold } %> | ||
</button> |
3 changes: 3 additions & 0 deletions
3
lib/sage_rails/app/views/sage_components/_sage_copy_text.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,3 @@ | ||
<span class="sage-copy-text <%= "sage-copy-text--semibold" if component.semibold.present? && component.semibold %>"> | ||
<%= component.value.html_safe %> | ||
</span> |
3 changes: 3 additions & 0 deletions
3
lib/sage_rails/app/views/sage_components/_sage_copy_text_card.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,3 @@ | ||
<div class="sage-copy-text-card <%= "sage-copy-text-card--semibold" if component.semibold.present? && component.semibold %>"> | ||
<%= component.content.html_safe %> | ||
</div> |