feat: improve navigation and add security scans
Security / Secrets (gitleaks) (push) Successful in 1m29s
Lint / Lint (push) Successful in 1m43s
Security / Dependencies (Trivy) (push) Successful in 1m59s
Security / Code (Semgrep) (push) Successful in 3m34s
Tests / Dashboard checks (push) Successful in 1m2s
Tests / Go backend (push) Successful in 3m13s
Docker / Docker Build & Push (push) Successful in 8m15s
Security / Secrets (gitleaks) (push) Successful in 1m29s
Lint / Lint (push) Successful in 1m43s
Security / Dependencies (Trivy) (push) Successful in 1m59s
Security / Code (Semgrep) (push) Successful in 3m34s
Tests / Dashboard checks (push) Successful in 1m2s
Tests / Go backend (push) Successful in 3m13s
Docker / Docker Build & Push (push) Successful in 8m15s
- Hide the lone navigation tab and show mobile menus as overlays - Add secret, code, and dependency scanning to CI - Update test workflows and remove an unused frontend dependency
This commit is contained in:
1 parent
85e6db67b5
commit
817236f349
23 files changed
+299
-74
No files matched your search
@@ -5,7 +5,7 @@
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"README.md"
|
||||
],
|
||||
"sideEffects": [
|
||||
@@ -15,7 +15,6 @@
|
||||
"svelte": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gabriel20xx/design-tokens": "0.1.1",
|
||||
"@lucide/svelte": "1.28.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -31,15 +30,15 @@
|
||||
"package": "svelte-package",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"svelte": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"svelte": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"svelte": "./dist/index.js",
|
||||
"import": "./dist/index.js"
|
||||
"types": "./src/index.ts",
|
||||
"svelte": "./src/index.ts",
|
||||
"import": "./src/index.ts"
|
||||
},
|
||||
"./styles.css": "./dist/styles.css",
|
||||
"./styles.css": "./src/lib/styles.css",
|
||||
"./package.json": "./package.json"
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,21 @@ function mixHex(hex: string, towards: number, weight: number): string {
|
||||
return `#${channels.map((c) => Math.round(c + (towards - c) * weight).toString(16).padStart(2, '0')).join('')}`
|
||||
}
|
||||
|
||||
// WCAG relative luminance of a #rrggbb color, from 0 (black) to 1 (white).
|
||||
function luminance(hex: string): number {
|
||||
const [red, green, blue] = [1, 3, 5].map((start) => {
|
||||
const channel = parseInt(hex.slice(start, start + 2), 16) / 255
|
||||
return channel <= 0.03928 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4
|
||||
})
|
||||
return 0.2126 * red + 0.7152 * green + 0.0722 * blue
|
||||
}
|
||||
|
||||
// WCAG contrast ratio between two #rrggbb colors, from 1 (no contrast) to 21 (black on white).
|
||||
function contrastRatio(a: string, b: string): number {
|
||||
const [lighter, darker] = [luminance(a), luminance(b)].sort((x, y) => y - x)
|
||||
return (lighter + 0.05) / (darker + 0.05)
|
||||
}
|
||||
|
||||
// The color is written to a stylesheet rather than inline on <html>. Shared and app CSS re-declare these
|
||||
// tokens on every [data-theme] element (the AppShell root, for one), and that declaration hides the value
|
||||
// <html> would pass down, so the choice never reached the app's UI. Targeting [data-theme] elements with
|
||||
@@ -83,7 +98,9 @@ function primaryDeclarations(color: PaletteColor, dark: boolean): string {
|
||||
// Hover is lighter on dark and darker on light, as in the shared theme. It is a hex value, not color-mix(),
|
||||
// because consumers such as the terminal read these tokens as plain colors.
|
||||
const hover = dark ? mixHex(primary, 255, 0.15) : mixHex(primary, 0, 0.15)
|
||||
const foreground = dark ? color.darkFg : '#ffffff'
|
||||
// Text on the primary is white or the palette's dark text, whichever reads better. Mid-tone light colors
|
||||
// are too light for white text, so the choice follows the color rather than the theme.
|
||||
const foreground = contrastRatio(primary, '#ffffff') >= contrastRatio(primary, color.darkFg) ? '#ffffff' : color.darkFg
|
||||
return [
|
||||
...primaryVars.map((name) => `${name}: ${primary} !important;`),
|
||||
`--sc-primary-hover: ${hover} !important;`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@import "@gabriel20xx/design-tokens/theme.css";
|
||||
@import '../../../design-tokens/theme.css';
|
||||
|
||||
:where(.sc-root, .sc-root *) {
|
||||
box-sizing: border-box;
|
||||
@@ -1111,13 +1111,23 @@ html[data-wide-layout='true'] .sc-main {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
/* Overlay the page below the header instead of wrapping onto a new row, so opening the menu
|
||||
doesn't push the content down. */
|
||||
.sc-nav {
|
||||
display: none;
|
||||
flex-basis: 100%;
|
||||
order: 4;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
left: 0;
|
||||
z-index: 20;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
padding-bottom: 0.25rem;
|
||||
max-height: calc(100dvh - 4rem);
|
||||
padding: 0.5rem 1rem 0.75rem;
|
||||
overflow-y: auto;
|
||||
background: var(--sc-surface);
|
||||
border-bottom: 1px solid var(--sc-border);
|
||||
box-shadow: var(--sc-shadow-lg);
|
||||
}
|
||||
|
||||
.sc-nav[data-open="true"] {
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
export default {
|
||||
preprocess: vitePreprocess()
|
||||
};
|
||||
export default {};
|
||||
@@ -36,12 +36,12 @@ describe('ProfileDialog password changes', () => {
|
||||
|
||||
await submit();
|
||||
expect(onSave).not.toHaveBeenCalled();
|
||||
expect(screen.getByText('Enter your current password to change it.')).toBeTruthy();
|
||||
expect(screen.getByText('Enter your current password to change your email or password.')).toBeTruthy();
|
||||
|
||||
await fill('currentPassword', 'old-password');
|
||||
await submit();
|
||||
expect(onSave).not.toHaveBeenCalled();
|
||||
expect(screen.getByText('Enter a current authenticator code to change your password.')).toBeTruthy();
|
||||
expect(screen.getByText('Enter a current authenticator code to change your email or password.')).toBeTruthy();
|
||||
|
||||
await fill('totpToken', '123456');
|
||||
await submit();
|
||||
|
||||
@@ -54,6 +54,13 @@ describe('primary color', () => {
|
||||
expect(styleText()).not.toContain('#db3e24');
|
||||
});
|
||||
|
||||
it('uses dark text on light colors where white would be hard to read', () => {
|
||||
applyPrimaryColor('app', 'Honey');
|
||||
const [light] = styleText().split("[data-theme='dark']");
|
||||
expect(light).toContain('--sc-primary-fg: #2a2b0d !important;');
|
||||
expect(light).not.toContain('--sc-primary-fg: #ffffff !important;');
|
||||
});
|
||||
|
||||
it('makes the hover lighter on dark and darker on light', () => {
|
||||
applyPrimaryColor('app', 'Clover');
|
||||
const [light, dark] = styleText().split("[data-theme='dark']");
|
||||
|
||||
Reference in new issue
Block a user