-
-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add <LinkButton>
component
#1784
base: main
Are you sure you want to change the base?
Changes from all commits
e6ba3b4
ed168b5
f9cd54c
50359b3
93b2de1
e273047
bf281c7
15580a8
c77c2ad
0a8be2f
71c7460
54beb60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/starlight': minor | ||
--- | ||
|
||
Adds `<LinkButton>` component for visually distinct and emphasized call to action links |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
'@astrojs/starlight': minor | ||
--- | ||
|
||
Changes the hero component action button default [variant](https://starlight.astro.build/reference/frontmatter/#heroconfig) from `minimal` to `primary`. | ||
|
||
If you want to preserve the previous behavior, hero component action button previously declared without a `variant` will need to be updated to include the `variant` property with the value `minimal`. | ||
|
||
```diff | ||
hero: | ||
actions: | ||
- text: View on GitHub | ||
link: https://github.com/astronaut/my-project | ||
icon: external | ||
+ variant: minimal | ||
``` |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,10 +62,10 @@ | |
font-size: var(--sl-text-h6); | ||
} | ||
|
||
.sl-markdown-content a:not(:where(.not-content *)) { | ||
.sl-markdown-content a:not(:where(:is(.not-content, .not-content *))) { | ||
color: var(--sl-color-text-accent); | ||
} | ||
.sl-markdown-content a:hover:not(:where(.not-content *)) { | ||
.sl-markdown-content a:hover:not(:where(:is(.not-content, .not-content *))) { | ||
Comment on lines
+65
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are used to avoid I'm wondering if this is a change that could be applied to some other places to avoid relying on a wrapping element to avoid Markdown styles 🤔 |
||
color: var(--sl-color-white); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
import type { HTMLAttributes } from 'astro/types'; | ||
import { Icons } from '../components/Icons'; | ||
import Icon from './Icon.astro'; | ||
|
||
interface Props extends Omit<HTMLAttributes<'a'>, 'href'> { | ||
href: string | URL; | ||
icon?: keyof typeof Icons | undefined; | ||
iconPlacement?: 'start' | 'end' | undefined; | ||
variant?: 'primary' | 'secondary' | 'minimal'; | ||
} | ||
|
||
const { | ||
class: className, | ||
icon, | ||
iconPlacement = 'end', | ||
variant = 'primary', | ||
...attrs | ||
} = Astro.props; | ||
--- | ||
|
||
<a class:list={['sl-link-button not-content', variant, className]} {...attrs}> | ||
{icon && iconPlacement === 'start' && <Icon name={icon} size="1.5rem" />} | ||
<slot /> | ||
{icon && iconPlacement === 'end' && <Icon name={icon} size="1.5rem" />} | ||
</a> | ||
|
||
<style> | ||
.sl-link-button { | ||
align-items: center; | ||
border-radius: 999rem; | ||
color: var(--sl-color-white); | ||
display: inline-flex; | ||
font-size: var(--sl-text-sm); | ||
gap: 0.5em; | ||
line-height: 1.7145; | ||
padding: 0.5rem 1.125rem; | ||
text-decoration: none; | ||
} | ||
|
||
.sl-link-button.primary { | ||
background: var(--sl-color-text-accent); | ||
border: 1px solid var(--sl-color-text-accent); | ||
color: var(--sl-color-black); | ||
} | ||
.sl-link-button.secondary { | ||
border: 1px solid; | ||
} | ||
.sl-link-button.minimal { | ||
outline-offset: 0.25rem; | ||
padding-inline: 0; | ||
} | ||
|
||
.sl-link-button :global(svg) { | ||
flex-shrink: 0; | ||
} | ||
|
||
@media (min-width: 50rem) { | ||
.sl-link-button { | ||
font-size: var(--sl-text-base); | ||
line-height: 1.5; | ||
padding: 1rem 1.25rem; | ||
} | ||
} | ||
|
||
:global(.sl-markdown-content) .sl-link-button { | ||
margin-inline-end: 0.5em; | ||
} | ||
:global(.sl-markdown-content) .sl-link-button:not(:where(p *)) { | ||
margin-block: 1rem; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to call this out in the changeset as well