Skip to content

Commit

Permalink
🎨 Mulighet for manuell sortering av elementer i grunnleggende-sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed May 24, 2023
1 parent 46af5de commit aa3b4c2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
10 changes: 10 additions & 0 deletions aksel.nav.no/website/components/layout/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ export const Sidebar = ({
return -1;
}

if (a.sidebarindex !== null || b.sidebarindex !== null) {
if (a.sidebarindex !== null && b.sidebarindex !== null) {
return a.sidebarindex - b.sidebarindex;
} else if (a.sidebarindex !== null) {
return -1;
} else {
return 1;
}
}

return a?.heading.localeCompare(b?.heading);
}),
}))
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/sanity/interface/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const sidebarQuery = `"sidebar": *[_type == $type && defined(kategori)] {
"slug": slug.current,
kategori,
"tag": status.tag,
"sidebarindex": sidebarindex,
}`;

export const landingPageQuery = (t) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export const GrunnleggendeArtikkel = defineType({
collapsed: false,
},
}),
defineField({
title: "Sidebar-index",
description:
"Overstyrer sortering av artikler i sidebar. Hvis feltet er tomt, sorteres den alfabetisk.",
name: "sidebarindex",
type: "number",
group: "settings",
}),
defineField({
title: "Innhold",
description:
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/types/sanity-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export type AkselSidebarT = Array<{
slug: string;
kategori: typeof komponentKategorier[number]["value"];
tag: "beta" | "new" | "ready" | "deprecated";
sidebarindex: number | null;
}>;

export type ArticleListT = Array<{
Expand Down
56 changes: 28 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3898,7 +3898,7 @@ __metadata:
languageName: node
linkType: hard

"@navikt/aksel-icons@^3.2.2, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
"@navikt/aksel-icons@^3.2.4, @navikt/aksel-icons@workspace:@navikt/aksel-icons":
version: 0.0.0-use.local
resolution: "@navikt/aksel-icons@workspace:@navikt/aksel-icons"
dependencies:
Expand All @@ -3925,7 +3925,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@navikt/aksel@workspace:@navikt/aksel"
dependencies:
"@navikt/ds-css": 3.2.2
"@navikt/ds-css": 3.2.4
"@types/inquirer": ^9.0.3
"@types/jest": ^29.0.0
axios: 1.3.6
Expand All @@ -3949,7 +3949,7 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-codemod@^3.2.2, @navikt/ds-codemod@workspace:@navikt/codemod":
"@navikt/ds-codemod@^3.2.4, @navikt/ds-codemod@workspace:@navikt/codemod":
version: 0.0.0-use.local
resolution: "@navikt/ds-codemod@workspace:@navikt/codemod"
dependencies:
Expand All @@ -3976,7 +3976,7 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-css-internal@^3.2.2, @navikt/ds-css-internal@workspace:@navikt/internal/css":
"@navikt/ds-css-internal@^3.2.4, @navikt/ds-css-internal@workspace:@navikt/internal/css":
version: 0.0.0-use.local
resolution: "@navikt/ds-css-internal@workspace:@navikt/internal/css"
dependencies:
Expand All @@ -3987,11 +3987,11 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-css@3.2.2, @navikt/ds-css@^3.2.2, @navikt/ds-css@workspace:@navikt/core/css":
"@navikt/ds-css@3.2.4, @navikt/ds-css@^3.2.4, @navikt/ds-css@workspace:@navikt/core/css":
version: 0.0.0-use.local
resolution: "@navikt/ds-css@workspace:@navikt/core/css"
dependencies:
"@navikt/ds-tokens": ^3.2.2
"@navikt/ds-tokens": ^3.2.4
cssnano: 6.0.0
fast-glob: 3.2.11
lodash: 4.17.21
Expand All @@ -4004,7 +4004,7 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-icons@^3.2.2, @navikt/ds-icons@workspace:@navikt/icons":
"@navikt/ds-icons@^3.2.4, @navikt/ds-icons@workspace:@navikt/icons":
version: 0.0.0-use.local
resolution: "@navikt/ds-icons@workspace:@navikt/icons"
dependencies:
Expand Down Expand Up @@ -4040,8 +4040,8 @@ __metadata:
"@babel/preset-env": 7.19.4
"@babel/preset-react": 7.18.6
"@babel/preset-typescript": 7.18.6
"@navikt/ds-icons": ^3.2.2
"@navikt/ds-react": ^3.2.2
"@navikt/ds-icons": ^3.2.4
"@navikt/ds-react": ^3.2.4
"@rollup/plugin-babel": 6.0.2
"@rollup/plugin-commonjs": 23.0.2
"@rollup/plugin-node-resolve": ^15.0.1
Expand All @@ -4066,12 +4066,12 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-react-internal@^3.2.2, @navikt/ds-react-internal@workspace:@navikt/internal/react":
"@navikt/ds-react-internal@^3.2.4, @navikt/ds-react-internal@workspace:@navikt/internal/react":
version: 0.0.0-use.local
resolution: "@navikt/ds-react-internal@workspace:@navikt/internal/react"
dependencies:
"@navikt/aksel-icons": ^3.2.2
"@navikt/ds-react": ^3.2.2
"@navikt/aksel-icons": ^3.2.4
"@navikt/ds-react": ^3.2.4
clsx: ^1.1.1
concurrently: 7.2.1
copy-to-clipboard: ^3.3.1
Expand All @@ -4087,12 +4087,12 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-react@3.2.2, @navikt/ds-react@^3.2.2, @navikt/ds-react@workspace:@navikt/core/react":
"@navikt/ds-react@3.2.4, @navikt/ds-react@^3.2.4, @navikt/ds-react@workspace:@navikt/core/react":
version: 0.0.0-use.local
resolution: "@navikt/ds-react@workspace:@navikt/core/react"
dependencies:
"@floating-ui/react": 0.17.0
"@navikt/aksel-icons": ^3.2.2
"@navikt/aksel-icons": ^3.2.4
"@radix-ui/react-tabs": 1.0.0
"@radix-ui/react-toggle-group": 1.0.0
"@testing-library/dom": 8.13.0
Expand Down Expand Up @@ -4128,11 +4128,11 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-tailwind@^3.2.2, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
"@navikt/ds-tailwind@^3.2.4, @navikt/ds-tailwind@workspace:@navikt/core/tailwind":
version: 0.0.0-use.local
resolution: "@navikt/ds-tailwind@workspace:@navikt/core/tailwind"
dependencies:
"@navikt/ds-tokens": ^3.2.2
"@navikt/ds-tokens": ^3.2.4
"@types/jest": ^29.0.0
color: 4.2.3
jest: ^29.0.0
Expand All @@ -4143,7 +4143,7 @@ __metadata:
languageName: unknown
linkType: soft

"@navikt/ds-tokens@^3.2.2, @navikt/ds-tokens@workspace:@navikt/core/tokens":
"@navikt/ds-tokens@^3.2.4, @navikt/ds-tokens@workspace:@navikt/core/tokens":
version: 0.0.0-use.local
resolution: "@navikt/ds-tokens@workspace:@navikt/core/tokens"
dependencies:
Expand Down Expand Up @@ -8302,15 +8302,15 @@ __metadata:
version: 0.0.0-use.local
resolution: "aksel.nav.no@workspace:aksel.nav.no"
dependencies:
"@navikt/aksel-icons": ^3.2.2
"@navikt/ds-codemod": ^3.2.2
"@navikt/ds-css": ^3.2.2
"@navikt/ds-css-internal": ^3.2.2
"@navikt/ds-icons": ^3.2.2
"@navikt/ds-react": ^3.2.2
"@navikt/ds-react-internal": ^3.2.2
"@navikt/ds-tailwind": ^3.2.2
"@navikt/ds-tokens": ^3.2.2
"@navikt/aksel-icons": ^3.2.4
"@navikt/ds-codemod": ^3.2.4
"@navikt/ds-css": ^3.2.4
"@navikt/ds-css-internal": ^3.2.4
"@navikt/ds-icons": ^3.2.4
"@navikt/ds-react": ^3.2.4
"@navikt/ds-react-internal": ^3.2.4
"@navikt/ds-tailwind": ^3.2.4
"@navikt/ds-tokens": ^3.2.4
prettier-plugin-tailwindcss: ^0.2.3
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -23360,8 +23360,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "shadow-dom@workspace:examples/shadow-dom"
dependencies:
"@navikt/ds-css": 3.2.2
"@navikt/ds-react": 3.2.2
"@navikt/ds-css": 3.2.4
"@navikt/ds-react": 3.2.4
"@types/react": ^18.0.0
"@types/react-dom": ^18.0.0
"@vitejs/plugin-react": ^2.1.0
Expand Down

0 comments on commit aa3b4c2

Please sign in to comment.