Skip to content

Commit 229993e

Browse files
committed
Refine Try it button styling
1 parent 8475eae commit 229993e

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

custom-app/src/Codeblock.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,36 @@ const ShikiCodeBlock = styled.div`
6666

6767
const RunButton = styled.button`
6868
background-color: ${({ theme }) =>
69-
theme.mode === 'dark' ? '#1C1C1C' : '#383838'};
70-
color: ${({ theme }) => (theme.mode === 'dark' ? '#EDEDED' : '#EDEDED')};
69+
theme.mode === 'dark' ? '#4C6FFF' : '#383838'};
70+
color: #ededed;
7171
padding: 6px 12px;
7272
border-radius: 100px;
73-
border: none;
73+
border: ${({ theme }) =>
74+
theme.mode === 'dark' ? '1px solid rgba(255, 255, 255, 0.16)' : 'none'};
7475
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
7576
font-family: monospace;
7677
display: flex;
7778
align-items: center;
7879
align-self: flex-start;
7980
gap: 8px;
81+
transition:
82+
background-color 150ms ease,
83+
color 150ms ease;
84+
85+
&:hover:not(:disabled) {
86+
background-color: ${({ theme }) =>
87+
theme.mode === 'dark' ? '#6C84FF' : '#4b5563'};
88+
}
89+
90+
&:focus-visible {
91+
outline: 2px solid
92+
${({ theme }) => (theme.mode === 'dark' ? '#A5B4FF' : '#E5E7EB')};
93+
outline-offset: 2px;
94+
}
95+
96+
&:disabled {
97+
opacity: 0.65;
98+
}
8099
`
81100

82101
const LoaderContainer = styled.div`
@@ -341,21 +360,8 @@ export const Codeblock: React.FC = () => {
341360
}}
342361
/>
343362
</div>
344-
<RunButton
345-
onMouseOver={(e) => {
346-
e.currentTarget.style.backgroundColor = isDark
347-
? '#4b5563'
348-
: '#4b5563'
349-
}}
350-
onMouseOut={(e) => {
351-
e.currentTarget.style.backgroundColor = isDark
352-
? '#1C1C1C'
353-
: '#383838'
354-
}}
355-
onClick={handleRun}
356-
disabled={runButtonDisabled}
357-
>
358-
RUN{' '}
363+
<RunButton onClick={handleRun} disabled={runButtonDisabled}>
364+
Try it{' '}
359365
<svg
360366
width="12"
361367
height="12"

0 commit comments

Comments
 (0)