improve text placement in buttons and text inputs on non-apple devices

This commit is contained in:
2026-07-05 02:23:03 +02:00
parent 0e239d06d8
commit 8ebd17c99c
9 changed files with 38 additions and 8 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ export const PageSectionNavigationBlock = ({
return ( return (
<li key={anchor}> <li key={anchor}>
<a href={`#${anchor}`} className="button"> <a href={`#${anchor}`} className="button">
{section.title} <span>{section.title}</span>
</a> </a>
</li> </li>
); );
+1 -1
View File
@@ -57,7 +57,7 @@ export const EventFilter = ({
data-active={activeCategories?.includes(category.slug)} data-active={activeCategories?.includes(category.slug)}
onClick={() => toggleCategory(category.slug)} onClick={() => toggleCategory(category.slug)}
> >
{category.name} <span>{category.name}</span>
</button> </button>
</li> </li>
))} ))}
+2 -1
View File
@@ -26,7 +26,8 @@ export function Icon({
)} )}
{type === "externalLink" && ( {type === "externalLink" && (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor"><path d="M257.39-235.61 197-296l381-381H238.39v-86h486v486h-86v-339.61l-381 381Z" /></svg> // glyph is drawn ~20u up-and-left of centre, so offset the viewBox to recentre it
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-20 -980 960 960" fill="currentColor"><path d="M257.39-235.61 197-296l381-381H238.39v-86h486v486h-86v-339.61l-381 381Z" /></svg>
)} )}
{type === "search" && ( {type === "search" && (
+1 -1
View File
@@ -14,7 +14,7 @@ export const Newsletter = ({ url }: { url?: string }) => {
<p>Meld deg vårt nyhetsbrev og hold deg oppdatert arrangementer og siste nytt!</p> <p>Meld deg vårt nyhetsbrev og hold deg oppdatert arrangementer og siste nytt!</p>
</div> </div>
<a href={link} target="_blank" className="button primary"> <a href={link} target="_blank" className="button primary">
Meld deg <span>Meld deg </span>
<Icon type="arrowRight" /> <Icon type="arrowRight" />
</a> </a>
</div> </div>
+3
View File
@@ -96,6 +96,9 @@ export function HomePageView({ home, events, news }: HomePageViewProps) {
<span>Åpningstider</span> <span>Åpningstider</span>
<Icon type="arrowRight" /> <Icon type="arrowRight" />
</Link> </Link>
<Link href="/praktisk#apningstider" className="button">
<span>Åpningstider</span>
</Link>
</div> </div>
<div className="pig"> <div className="pig">
<Pig type="point" /> <Pig type="point" />
+2 -1
View File
@@ -221,7 +221,8 @@
.searchIcon { .searchIcon {
position: absolute; position: absolute;
right: 1rem; right: 1rem;
bottom: .6rem; top: 50%;
transform: translateY(-50%);
} }
@media (max-width: 1200px) { @media (max-width: 1200px) {
@@ -32,7 +32,8 @@
.searchIcon { .searchIcon {
position: absolute; position: absolute;
right: 1.2rem; right: 1.2rem;
bottom: .6rem; top: 50%;
transform: translateY(-50%);
} }
.resultItem { .resultItem {
+4
View File
@@ -131,12 +131,16 @@ input[type="text"] {
font-family: inherit; font-family: inherit;
font-size: var(--font-size-body); font-size: var(--font-size-body);
font-weight: 500; font-weight: 500;
text-box-trim: trim-both;
text-box-edge: cap alphabetic;
transition: opacity var(--transition-easing); transition: opacity var(--transition-easing);
&::placeholder { &::placeholder {
font-weight: 400; font-weight: 400;
color: currentColor; color: currentColor;
opacity: .6; opacity: .6;
text-box-trim: trim-both;
text-box-edge: cap alphabetic;
} }
&:focus, &:hover { &:focus, &:hover {
+20
View File
@@ -24,6 +24,26 @@ button,
text-decoration: none; text-decoration: none;
} }
// Trim label leading for consistent text centering, re-add it as padding to keep height
@supports (text-box-trim: trim-both) {
& > span:not(:has(svg)) { // labels, not the icon (also a child <span>)
text-box-trim: trim-both;
text-box-edge: cap alphabetic;
}
&:has(svg) { // icon anchors height → re-add on the button
--trim-comp: 0.25em; // half of the leading removed
padding-block: calc(var(--spacing-xs) + var(--trim-comp));
&.cta { padding-block: calc(var(--spacing-xs) * 1.5 + var(--trim-comp)); }
&.tertiary { padding-block: calc(.2rem + var(--trim-comp)); }
&.toggler { padding-block: calc(.25rem + var(--trim-comp)); }
}
&.toggler:not(:has(svg)) { padding-block: calc(.25rem); } // icon anchors height
&:not(:has(svg)):not(.toggler) > span { padding-block: 0.4em; } // nothing → on the label
}
&.cta { &.cta {
padding: calc(var(--spacing-xs)*1.5) calc(var(--spacing-s)*1.5); padding: calc(var(--spacing-xs)*1.5) calc(var(--spacing-s)*1.5);
display: inline-flex; display: inline-flex;