Skip to content
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

Implement clickable color swatches to copy color props to clipboard #476

Merged
merged 32 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
160dd46
replace color swatch spans with buttons
Brian-Pob Feb 7, 2024
0e797e4
add click to copy functionality
Brian-Pob Feb 7, 2024
eca161c
update color swatch css for use with buttons
Brian-Pob Feb 7, 2024
9ae5f44
add basic markup and rough styles for copy option selector
Brian-Pob Feb 7, 2024
096ecfa
move color copy css to separate file
Brian-Pob Feb 8, 2024
3e251d9
move javascript to separate file
Brian-Pob Feb 9, 2024
afb76b0
add tooltip functionality and styles
Brian-Pob Feb 9, 2024
aa8d6ec
update index.css for tooltips
Brian-Pob Feb 9, 2024
8daf6a6
implement selecting format for copied color
Brian-Pob Feb 9, 2024
e74d56b
change tooltip style to match buttons
Brian-Pob Feb 10, 2024
bd42eaa
clean up js
Brian-Pob Feb 10, 2024
0647081
move checkbox outside of label and refactor css to match
Brian-Pob Feb 12, 2024
37c6bcd
started implementing roving-ux
Brian-Pob Feb 21, 2024
cb1673c
Merge branch 'argyleink:main' into main
Brian-Pob Feb 21, 2024
8319195
replaced color swatches with lists
Brian-Pob Feb 23, 2024
09929b4
style copy type selectors
Brian-Pob Feb 23, 2024
f43372a
Merge branch 'argyleink:main' into main
Brian-Pob Feb 23, 2024
a006513
added missing 12th color swatch
Brian-Pob Feb 23, 2024
b8bc51f
remove unnecessary classes
Brian-Pob Feb 24, 2024
1d59fe1
update package-lock
Brian-Pob Feb 24, 2024
d1890d0
fix mobile layout and make tooltips unclickable
Brian-Pob Feb 24, 2024
882a266
fix animation not playing when first clicking
Brian-Pob Feb 24, 2024
78bfba0
fix misshapen outline on tabover
Brian-Pob Feb 24, 2024
ec41508
fix color of copy options when light mode
Brian-Pob Feb 24, 2024
9eb507f
fix ease squish animation speed
Brian-Pob Feb 24, 2024
53e8631
change copy example to reflect default selected option
Brian-Pob Feb 28, 2024
4e4dfd3
Merge branch 'argyleink:main' into main
Brian-Pob Feb 29, 2024
dd3d672
Apply suggestions from code review
Brian-Pob Mar 3, 2024
955409a
move color conversion to separate file
Brian-Pob Mar 9, 2024
5abac60
Merge branch 'main' of https://github.com/Brian-Pob/open-props
Brian-Pob Mar 9, 2024
349514f
Merge branch 'argyleink:main' into main
Brian-Pob Mar 9, 2024
a3a0fbb
Merge branch 'main' of https://github.com/Brian-Pob/open-props
Brian-Pob Mar 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions docsite/color-copy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
.copy-options {
font-family: var(--font-sans);
display: flex;
flex-wrap: wrap;
flex-direction: row;
gap: var(--size-3);

& .example {
font-style: italic;
color: var(--text-2);
}

[data-theme="light"] & .example {
color: var(--gray-7);
}

& input:is(:disabled) {

Brian-Pob marked this conversation as resolved.
Show resolved Hide resolved
cursor: not-allowed;

&~label {
color: var(--gray-5);
cursor: not-allowed;
}
}

@media (--md-n-below) {
flex-direction: column;
}
}

.options {
display: flex;
flex-wrap: wrap;
gap: var(--size-7);
align-items: center;
justify-content: flex-start;
padding-inline: var(--size-4);
padding-block: var(--size-3);
margin: var(--size-2) 0;
overflow: auto;
border-radius: var(--radius-conditional-2);
border: var(--border-size-1) solid var(--surface-3);
background: white;
box-shadow: var(--shadow-4);

[data-theme="dark"] & {
background: var(--surface-2);
box-shadow: var(--shadow-3);
}

@media (max-width: 768px) {
flex-direction: column;
align-items: start;
}
}

.options:nth-child(2) {
gap: var(--size-5);

Brian-Pob marked this conversation as resolved.
Show resolved Hide resolved
}

.input-group {

Brian-Pob marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
align-items: center;
/* justify-content: flex-start; */
& > label {
padding-inline-start: var(--size-2);
}
}

.color-format:has(:disabled) {
color: var(--gray-5);
}

.tooltip {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: -100%;
min-width: max-content;
border-radius: var(--radius-round);
padding: var(--size-1) var(--size-2);
font-size: var(--size-2);
background-color: #000;
color: #fff;
z-index: 9999;
pointer-events: none;

}

.tooltip-show {
animation: var(--animation-fade-in) forwards;
animation-duration: 0.5s;
}

.tooltip-hide {
animation: var(--animation-fade-out) forwards;
animation-duration: 0.5s;
}

.color-swatch:has(.tooltip) {
position: relative;
}

.color-swatch-list {
list-style: none;
}
81 changes: 56 additions & 25 deletions docsite/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@import "../src/props.masks.corner-cuts.css";

@import "./syntax-highlight.css";
@import "./color-copy.css";

:root {
--max-inline-body: calc(100vw - (var(--size-8) * 2));
Expand Down Expand Up @@ -456,7 +457,7 @@ pre[class*="language-"] {
& > h4 {
counter-reset: basic -1;
}

& > h4::before {
display: none;
}
Expand Down Expand Up @@ -512,50 +513,75 @@ pre[class*="language-"] {
}
}

.color-swatch {
.color-swatch-list {
padding-inline-start: 0;
}

.color-swatch-list > li {
--scale: 1.5;
--size: var(--size-5);
border-radius: var(--radius-round);
box-shadow: var(--inner-shadow-0);
padding-inline-start: 0;
inline-size: 6.7%;
block-size: var(--size);
display: grid;
place-content: center;
color: black;
text-shadow: 0 0 1px hsl(0 0% 0% / 40%);

&::before {
opacity: 0;
transition: opacity .4s var(--ease-out-3);
}

&:nth-child(n+8)::before {
&:nth-child(n+8)>button::before {
color: white;
}

&:is(:hover,:focus) {
transform: scale(1.5);
&:is(:hover, :focus-visible),
&:has(button:is(:focus-visible))
{
transform: scale(var(--scale));
transition-delay: 0s;
transition-timing-function: var(--ease-elastic-out-3);

&::before {
& > button::before {
opacity: 1;
}
}

&:is(:active) {
transform: scale(calc(var(--scale) * .88)) !important;
}

@media (--motionOK) {
transition: transform 2s var(--ease-squish-5) 3s;
transition: transform var(--ease-squish-5);
transition-duration: 2s;
transition-delay: 3s;

&:is(:hover,:focus) {
&:is(:hover, :focus-visible),
&:has(button:is(:focus-visible)) {
transition-duration: .1s;
}
}

@media (--md-n-below) {
--size: var(--size-3);
}

@media (--xs-n-below) {
--size: var(--size-2);
}

}

.color-swatch {
padding-inline: 0;
border-radius: var(--radius-round);
box-shadow: var(--inner-shadow-0);
inline-size: 100%;
block-size: var(--size);
display: grid;
place-content: center;
color: black;
text-shadow: 0 0 1px hsl(0 0% 0% / 40%);

&::before {
opacity: 0;
transition: opacity .4s var(--ease-out-3);
line-height: 1;
}

}

.ui-gradients {
Expand Down Expand Up @@ -1245,13 +1271,18 @@ pre[class*="language-"] {

.count-em {

&::before {
content: '';
counter-reset: basic;
position: absolute;
}
&:not(.tooltip, li):before {
Brian-Pob marked this conversation as resolved.
Show resolved Hide resolved
content: '';
counter-reset: basic -1;
position: absolute;
}

& > *:not(.tooltip, li):before {
Brian-Pob marked this conversation as resolved.
Show resolved Hide resolved
counter-increment: basic;
content: counter(basic);
}

& > *::before {
& button:before {
Brian-Pob marked this conversation as resolved.
Show resolved Hide resolved
counter-increment: basic;
content: counter(basic);
}
Expand Down
Loading
Loading