Skip to content

Commit

Permalink
Transition and fix overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Oct 1, 2023
1 parent 39ab561 commit 1846eae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/lib/themeEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const themeEffect = function () {
pref === "dark" ||
(!pref && window.matchMedia("(prefers-color-scheme: dark)").matches)
) {
// TODO: Add [color-scheme:dark]
d.classList.add("dark")
result = "dark"
} else {
Expand Down
25 changes: 14 additions & 11 deletions config/rehype-callout.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,42 @@ export default function rehypeCallout() {
const icon = iconMap[type] ?? info

parent.children.splice(index, 1, {
type: "element",
tagName: "aside",
children: [
{
...icon,
properties: {
...icon.properties,
class: [
"w-9 h-9 absolute top-1 right-1 p-1.5",
"w-9 h-9 absolute top-1 right-1 p-1.5 transition-colors",
type === "INFO" && "text-indigo-600 dark:text-indigo-400",
type === "WARN" && "text-yellow-700 dark:text-yellow-500",
type === "ERROR" && "text-red-600 dark:text-red-500",
].filter(Boolean),
},
},
{
children: [{ type: "text", value: title }],
type: "element",
tagName: "strong",
properties: {
className: "text-zinc-900 dark:text-white font-bold mb-2 block",
className:
"text-zinc-900 dark:text-white font-bold mb-2 block transition-colors",
},
tagName: "strong",
type: "element",
children: [{ type: "text", value: title }],
},
{
children: children.slice(2),
properties: { className: "text-zinc-700 dark:text-zinc-200" },
tagName: "div",
type: "element",
tagName: "div",
properties: {
className: "text-zinc-700 dark:text-zinc-200 transition-colors",
},
children: children.slice(2),
},
],
properties: {
class: [
"px-4 -mx-4 relative dark:text-white",
"px-4 -mx-4 relative dark:text-white transition-colors",
"sm:rounded sm:-mr-6 sm:-ml-7 py-4 sm:px-6 sm:border-l-4",
type === "INFO" &&
"bg-indigo-300/50 border-indigo-500 dark:bg-indigo-900/50 dark:border-indigo-500",
Expand All @@ -66,8 +71,6 @@ export default function rehypeCallout() {
"bg-red-300/50 border-red-500 dark:bg-red-900/50 dark:border-red-500",
].filter(Boolean),
},
tagName: "aside",
type: "element",
})

return SKIP
Expand Down
26 changes: 15 additions & 11 deletions tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ module.exports = {
marginBottom: theme("spacing.10"),
},
p: {
...transition,
marginTop: theme("spacing.7"),
marginBottom: theme("spacing.7"),
},
Expand Down Expand Up @@ -319,26 +320,29 @@ module.exports = {
".code-block:not(:is(.has-title, .demo)) :is(pre, code)": {
borderRadius: theme("borderRadius.xl"),
},
"pre:not(.collapsed) code .line:is(.highlight, .focus)": {
backgroundColor: "var(--tw-prose-hl-bg)",
borderColor: "var(--tw-prose-hl-border)",
"pre code .line": {
...transition,
transitionDuration: theme("transitionDuration.300"),
transitionProperty:
"height, border-color, background-color, clip-path",
borderColor: "transparent",
borderLeftWidth: theme("borderWidth.4"),
clipPath: "inset(0 0 0 0)",
display: "inline-block",
height: theme("spacing.7"),
marginInline: `calc(${theme("spacing.8")} * -1)`,
paddingRight: theme("spacing.8"),
paddingLeft: `calc(${theme("spacing.8")} - ${theme(
"borderWidth.4",
)})`,
width: `calc(100% + ${theme("spacing.16")})`,
paddingRight: theme("spacing.8"),
},
"pre code .line": {
...transition,
transitionProperty: "height",
transitionDuration: theme("transitionDuration.300"),
height: theme("spacing.7"),
overflowY: "hidden",
"pre:not(.collapsed) code .line:is(.highlight, .focus)": {
width: `calc(100% + ${theme("spacing.16")})`,
backgroundColor: "var(--tw-prose-hl-bg)",
borderColor: "var(--tw-prose-hl-border)",
},
"pre.collapsed code .line:not(.focus)": {
clipPath: "inset(100% 0 0 0)",
height: 0,
},

Expand Down

0 comments on commit 1846eae

Please sign in to comment.