fix copy
This commit is contained in:
parent
aefd2f4a35
commit
c582f32aca
4 changed files with 85 additions and 29 deletions
38
src/app.css
38
src/app.css
|
|
@ -495,7 +495,7 @@ pre button.copy {
|
||||||
backdrop-filter: blur(8px);
|
backdrop-filter: blur(8px);
|
||||||
-webkit-backdrop-filter: blur(8px);
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
|
||||||
@apply bg-background/80 hover:bg-background border-border hover:border-border/60 rounded-md border shadow-sm hover:shadow-md; /* Text color removed from here */
|
@apply bg-background/80 hover:bg-background border-border hover:border-border/60 hover:text-foreground rounded-md border shadow-sm hover:shadow-md;
|
||||||
|
|
||||||
/* Improved hover and focus states */
|
/* Improved hover and focus states */
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
@ -519,12 +519,14 @@ pre button.copy {
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
/* Default filter for light mode (assuming black/dark SVGs) */
|
background-color: transparent !important;
|
||||||
filter: brightness(0.2) sepia(1) saturate(5) hue-rotate(240deg); /* Adjust hue-rotate to match your muted-foreground */
|
}
|
||||||
|
& svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
& .ready {
|
& .ready {
|
||||||
background-color: transparent;
|
|
||||||
background-image: url(/icons/copy.svg);
|
background-image: url(/icons/copy.svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -535,12 +537,8 @@ pre button.copy {
|
||||||
}
|
}
|
||||||
|
|
||||||
&.copied {
|
&.copied {
|
||||||
/* Light mode success state colors */
|
/* Light mode success state (dark blue text on light background) */
|
||||||
@apply bg-primary/10 border-primary/30;
|
@apply bg-primary/10 border-primary/30 text-primary;
|
||||||
/* Filter for success icon in light mode (e.g., primary color) */
|
|
||||||
& span {
|
|
||||||
filter: brightness(0.5) sepia(1) saturate(5) hue-rotate(240deg); /* Adjust to primary color */
|
|
||||||
}
|
|
||||||
|
|
||||||
& .success {
|
& .success {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
@ -553,21 +551,11 @@ pre button.copy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dark mode adjustments for copy button */
|
/* Dark mode adjustments for copy button success state */
|
||||||
.dark pre button.copy {
|
.dark pre button.copy.copied {
|
||||||
& span {
|
/* Dark mode success state (light blue text on dark background) */
|
||||||
/* Filter for dark mode (turn icons white/light) */
|
@apply bg-primary/20 border-primary/40 text-primary-foreground;
|
||||||
filter: invert(1) brightness(1.2); /* Invert and brighten for white/light icons */
|
/* Using primary-foreground which is white/light for better visibility */
|
||||||
}
|
|
||||||
|
|
||||||
&.copied {
|
|
||||||
/* Dark mode success state colors */
|
|
||||||
@apply bg-primary/20 border-primary/40;
|
|
||||||
/* Filter for success icon in dark mode (e.g., primary-foreground color) */
|
|
||||||
& span {
|
|
||||||
filter: invert(1) brightness(1.2); /* Keep them white/light for dark mode success */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy success animation */
|
/* Copy success animation */
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,41 @@ md.use(
|
||||||
{
|
{
|
||||||
name: 'shiki-transformer-copy-button',
|
name: 'shiki-transformer-copy-button',
|
||||||
pre(node) {
|
pre(node) {
|
||||||
|
const copyIcon = h(
|
||||||
|
'svg',
|
||||||
|
{
|
||||||
|
width: '24',
|
||||||
|
height: '24',
|
||||||
|
viewBox: '0 0 24 24',
|
||||||
|
fill: 'none',
|
||||||
|
stroke: 'currentColor',
|
||||||
|
'stroke-width': '2',
|
||||||
|
'stroke-linecap': 'round',
|
||||||
|
'stroke-linejoin': 'round',
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h('rect', { width: '14', height: '14', x: '8', y: '8', rx: '2', ry: '2' }),
|
||||||
|
h('path', {
|
||||||
|
d: 'M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2',
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
const checkIcon = h(
|
||||||
|
'svg',
|
||||||
|
{
|
||||||
|
width: '24',
|
||||||
|
height: '24',
|
||||||
|
viewBox: '0 0 24 24',
|
||||||
|
fill: 'none',
|
||||||
|
stroke: 'currentColor',
|
||||||
|
'stroke-width': '2',
|
||||||
|
'stroke-linecap': 'round',
|
||||||
|
'stroke-linejoin': 'round',
|
||||||
|
},
|
||||||
|
[h('path', { d: 'M20 6 9 17l-5-5' })]
|
||||||
|
);
|
||||||
|
|
||||||
const button = h(
|
const button = h(
|
||||||
'button',
|
'button',
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +65,16 @@ md.use(
|
||||||
setTimeout(() => this.classList.remove('copied'), ${3000})
|
setTimeout(() => this.classList.remove('copied'), ${3000})
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
[h('span', { class: 'ready' }), h('span', { class: 'success' })]
|
[
|
||||||
|
h('span', { class: 'ready', style: 'background-color: transparent !important;' }, [
|
||||||
|
copyIcon,
|
||||||
|
]),
|
||||||
|
h(
|
||||||
|
'span',
|
||||||
|
{ class: 'success', style: 'background-color: transparent !important;' },
|
||||||
|
[checkIcon]
|
||||||
|
),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
node.children.push(button);
|
node.children.push(button);
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,12 @@
|
||||||
|
<svg
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5" /></svg
|
||||||
|
>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 273 B |
|
|
@ -1 +1,15 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="2"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
class="lucide lucide-copy-icon lucide-copy"
|
||||||
|
><rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path
|
||||||
|
d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 373 B |
Loading…
Add table
Reference in a new issue