Skip to content

Commit 840958d

Browse files
committed
Add padding to margin bottom of callouts, refactor css stylings from style block to tailwind styles in component
1 parent e0fb7ce commit 840958d

4 files changed

Lines changed: 253 additions & 238 deletions

File tree

‎_TODO.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ Let's work through each article section by section based on the H2 headers in th
206206
- Remove dotted underline from abbr elements? Or some other way of indicating abbreviations?
207207
- [Link](url) [[color=pink target=_blank .centered]] is not picking up styles
208208
- We have remark-mark-plus to create marked text like ==mark me==. Is the Highlighter component our social highlighter?
209-
- Make sure underline style in Core Markdown section is correct
210209
- Are we using breakpoints correctly - isn't iPhone wider than our `sm` breakpoint?
211210
- Mermaid theming, horizontal layout for desktop, vertical for mobile, using groups like in Code Tabs to add the media selectors e.g. `[g1:desktop]`
212211

‎src/components/Callout/index.astro‎

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,82 +28,82 @@ const iconMap = {
2828
danger: 'warning',
2929
} as const
3030
31-
// Map callout types to their background color CSS custom properties
32-
const backgroundColorMap = {
33-
warning: 'var(--color-warning-inverse)',
34-
action: 'var(--color-warning-inverse)',
35-
info: 'var(--color-info-inverse)',
36-
tip: 'var(--color-success-inverse)',
37-
note: 'var(--color-note-inverse)',
38-
success: 'var(--color-success-inverse)',
39-
danger: 'var(--color-danger-inverse)',
31+
const typeContainerClassMap = {
32+
warning: 'bg-warning-inverse border-warning',
33+
action: 'bg-warning-inverse border-warning',
34+
info: 'bg-info-inverse border-info',
35+
tip: 'bg-success-inverse border-success',
36+
note: 'bg-note-inverse border-note',
37+
success: 'bg-success-inverse border-success',
38+
danger: 'bg-danger-inverse border-danger',
4039
} as const
4140
42-
// Map callout types to their border/icon color CSS custom properties
43-
const borderColorMap = {
44-
warning: 'var(--color-warning)',
45-
action: 'var(--color-warning)',
46-
info: 'var(--color-info)',
47-
tip: 'var(--color-success)',
48-
note: 'var(--color-note)',
49-
success: 'var(--color-success)',
50-
danger: 'var(--color-danger)',
41+
const typeAccentTextClassMap = {
42+
warning: 'text-warning',
43+
action: 'text-warning',
44+
info: 'text-info',
45+
tip: 'text-success',
46+
note: 'text-note',
47+
success: 'text-success',
48+
danger: 'text-danger',
5149
} as const
5250
5351
const icon = iconMap[type] ?? iconMap.info
54-
const backgroundColor = backgroundColorMap[type] ?? backgroundColorMap.info
55-
const borderColor = borderColorMap[type] ?? borderColorMap.info
5652
const typeLabel = typeLabelMap[type] ?? typeLabelMap.info
5753
const typeLabelUpper = typeLabel.toUpperCase()
58-
---
59-
60-
<style define:vars={{ backgroundColor, borderColor }}>
61-
.callout {
62-
background-color: var(--backgroundColor);
63-
border: 0;
64-
border-left: 6px solid var(--borderColor);
65-
border-radius: 0;
66-
display: flex;
67-
flex-direction: column;
68-
gap: 0.75rem;
69-
padding: 1rem;
70-
}
71-
72-
.callout__header {
73-
align-items: center;
74-
display: flex;
75-
gap: 0.5rem;
76-
}
7754
78-
.callout__icon {
79-
color: var(--borderColor);
80-
transform: translateY(-2px);
81-
}
55+
const containerClasses = typeContainerClassMap[type] ?? typeContainerClassMap.info
56+
const accentTextClasses = typeAccentTextClassMap[type] ?? typeAccentTextClassMap.info
57+
---
8258

59+
<style>
8360
.callout__icon :global(svg) {
8461
fill: currentcolor;
8562
}
8663

87-
.callout__label {
88-
color: var(--borderColor);
89-
font-size: 1rem;
90-
font-weight: bold;
91-
letter-spacing: 0.08em;
92-
text-transform: uppercase;
93-
}
94-
9564
/* Spacing for nested elements */
9665
.callout__content > :not(.sr-only) + :not(.sr-only) {
9766
margin-top: 2rem;
9867
}
9968
</style>
10069

101-
<div class="callout" role="note">
102-
<div class="callout__header">
103-
<div class="callout__icon">
70+
<div
71+
class:list={[
72+
containerClasses,
73+
'callout',
74+
'flex',
75+
'flex-col',
76+
'gap-3',
77+
'mb-6',
78+
'p-4',
79+
'border-0',
80+
'border-l-[6px]',
81+
'rounded-none',
82+
]}
83+
role="note"
84+
>
85+
<div class="flex items-center gap-2">
86+
<div
87+
class:list={[
88+
accentTextClasses,
89+
'callout__icon',
90+
'-translate-y-0.5',
91+
]}
92+
>
10493
<Icon name={icon} size={20} variant="custom" />
10594
</div>
106-
<div class="callout__label" aria-hidden="true">{typeLabelUpper}</div>
95+
<div
96+
class:list={[
97+
accentTextClasses,
98+
'text-base',
99+
'font-bold',
100+
'tracking-[0.08em]',
101+
'uppercase',
102+
]}
103+
aria-hidden="true"
104+
>
105+
{typeLabelUpper}
106+
</div>
107107
</div>
108108

109109
<div class="callout__content">

0 commit comments

Comments
 (0)