Skip to content

Commit

Permalink
update copy button style
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyu1818 committed Jun 8, 2024
1 parent e85b62f commit dc19539
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/app/(article)/posts/[id]/shiki.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,8 @@
.mdx-components pre {
@apply my-0;
}

/* mdx component */
.mdx-components .copy-button {
@apply right-3;
}
6 changes: 4 additions & 2 deletions src/markdown/components/copy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export const CopyButton = (props: CopyButtonProps) => {
return (
<button
className={clsx(
'absolute right-3 top-3 hidden rounded p-2 hover:bg-color-1/10 group-hover:block',
copied ? '!block bg-color-1/10 text-green-500' : 'text-gray-500',
'copy-button absolute right-1 top-6 hidden -translate-y-1/2 rounded p-2 hover:bg-gray-100 group-hover:block dark:hover:bg-gray-700 md:-right-4',
copied
? '!block bg-gray-100 text-green-500 dark:bg-gray-700'
: 'text-gray-500',
)}
onClick={handleClick}
>
Expand Down
2 changes: 1 addition & 1 deletion src/markdown/components/pre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Pre = (props: PreProps) => {
const { className, content, children, ...rest } = props
return (
<div className='relative'>
<pre {...rest} className={clsx('group relative', className)}>
<pre {...rest} className={clsx('group', className)}>
{children}
{content && <CopyButton content={content} />}
</pre>
Expand Down

0 comments on commit dc19539

Please sign in to comment.