Skip to content

Commit 667e307

Browse files
committed
Update color block frame design
1 parent 7f79efe commit 667e307

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/components/Editor.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import clsx from 'clsx'
22
import { TabBar } from '@/components/TabBar'
33

4-
export function Frame({ className = '', children }) {
4+
const frameColors = {
5+
sky: 'from-sky-500 to-cyan-300',
6+
indigo: 'from-indigo-500 to-blue-400',
7+
pink: 'from-pink-500 to-fuchsia-400',
8+
fuchsia: 'from-fuchsia-500 to-purple-400',
9+
purple: 'from-violet-500 to-purple-500',
10+
}
11+
12+
export function Frame({ className, color = 'sky', children }) {
513
return (
614
<div
7-
className={`${className} relative isolate bg-sky-400 pt-12 pl-12 rounded-2xl overflow-hidden`}
15+
className={clsx(
16+
className,
17+
frameColors[color],
18+
'relative -mx-4 pt-6 pl-4 bg-gradient-to-b sm:mx-0 sm:rounded-2xl sm:pt-12 sm:pl-12'
19+
)}
820
>
9-
<div
10-
className="absolute -inset-y-px -left-3 -z-10 w-full origin-bottom-left skew-x-[-30deg] bg-sky-100 opacity-20 ring-1 ring-inset ring-white"
11-
aria-hidden="true"
12-
/>
13-
14-
<div className="rounded-tl-xl overflow-hidden">{children}</div>
15-
16-
<div
17-
className="pointer-events-none absolute inset-0 ring-1 ring-inset ring-black/10 rounded-2xl dark:ring-1 dark:ring-white/10 dark:ring-inset"
18-
aria-hidden="true"
19-
/>
21+
<div className="rounded-tl-xl overflow-hidden sm:rounded-br-xl">{children}</div>
2022
</div>
2123
)
2224
}
@@ -43,12 +45,12 @@ export function EditorPane({ filename, scroll = false, children }) {
4345
)
4446
}
4547

46-
export function Editor({ filename, scroll = false, style = 'plain', children }) {
48+
export function Editor({ filename, scroll = false, style = 'plain', color, children }) {
4749
let passthrough = { scroll }
4850

4951
if (style === 'framed') {
5052
return (
51-
<Frame className="mt-5 mb-8 first:mt-0 last:mb-0">
53+
<Frame className="mt-5 mb-8 first:mt-0 last:mb-0" color={color}>
5254
<EditorPane {...passthrough} filename={filename}>
5355
{children}
5456
</EditorPane>

src/components/SnippetGroup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ let snippetGroupWrappers = {
8989
plain({ children }) {
9090
return <div className="not-prose bg-slate-800 rounded-xl shadow-md">{children}</div>
9191
},
92-
framed({ children }) {
92+
framed({ children, ...props }) {
9393
return (
94-
<Frame>
94+
<Frame {...props}>
9595
<div className="not-prose bg-slate-800 rounded-tl-xl shadow-md">{children}</div>
9696
</Frame>
9797
)
@@ -104,13 +104,13 @@ let snippetGroupWrappers = {
104104
* @param {object} props
105105
* @param {CodeBlock[]} props.children
106106
*/
107-
export function SnippetGroup({ children, style = 'plain', actions }) {
107+
export function SnippetGroup({ children, style = 'plain', actions, ...props }) {
108108
let [selectedIndex, setSelectedIndex] = useState(0)
109109

110110
let Wrapper = snippetGroupWrappers[style]
111111

112112
return (
113-
<Wrapper>
113+
<Wrapper {...props}>
114114
<Tab.Group as="div" onChange={setSelectedIndex}>
115115
<div className="flex">
116116
<Tab.List className="flex text-slate-400 text-xs leading-6 overflow-hidden rounded-tl-xl pt-2">

0 commit comments

Comments
 (0)