the great typeinfo unfuckening
This commit is contained in:
parent
db63f5639f
commit
49fed51ced
15 changed files with 233 additions and 365 deletions
|
|
@ -1,48 +1,18 @@
|
|||
---
|
||||
import { ThemeSelect } from "@components/hooks/ThemeSwitch";
|
||||
import { getTypeData } from "@config/io/generateTypeData";
|
||||
import type { TypeData } from "@config/io/types";
|
||||
import Nav from "@components/navigation/sidebars/nav/index.astro";
|
||||
import TOC from "@components/navigation/sidebars/TOC.astro";
|
||||
import type { TypeTOC } from "./navigation/sidebars/types";
|
||||
import type { ConfigHeading } from "@components/navigation/sidebars/types";
|
||||
import Search from "./navigation/Search.astro";
|
||||
|
||||
const routes = await getTypeData();
|
||||
|
||||
const url = Astro.url.pathname.split("/");
|
||||
const currentClass = url[4];
|
||||
const currentData = routes.find(
|
||||
item => item.name === currentClass
|
||||
);
|
||||
|
||||
const data = currentData?.data;
|
||||
const tocFunctions =
|
||||
data?.functions?.map(item => item.name) || null;
|
||||
|
||||
const propsKeys = data?.properties
|
||||
? Object.keys(data.properties)
|
||||
: null;
|
||||
const signalKeys = data?.signals
|
||||
? Object.keys(data.signals)
|
||||
: null;
|
||||
const variantKeys = data?.variants
|
||||
? Object.keys(data.variants)
|
||||
: null;
|
||||
|
||||
let sidebarData: TypeTOC | undefined = {
|
||||
properties: propsKeys,
|
||||
functions: tocFunctions,
|
||||
signals: signalKeys,
|
||||
variants: variantKeys,
|
||||
};
|
||||
|
||||
if (!data) {
|
||||
sidebarData = undefined;
|
||||
interface Props {
|
||||
title?: string;
|
||||
headings?: ConfigHeading[];
|
||||
type?: TypeData;
|
||||
}
|
||||
|
||||
const {
|
||||
title = null,
|
||||
headings = [],
|
||||
} = Astro.props;
|
||||
const { title, headings, type } = Astro.props;
|
||||
---
|
||||
<div class="header">
|
||||
<div class="header-item header-left">
|
||||
|
|
@ -54,6 +24,6 @@ const {
|
|||
<div class="header-item header-right">
|
||||
<Search/>
|
||||
<ThemeSelect client:load />
|
||||
<TOC title={title} headings={headings} types={sidebarData} mobile={true}/>
|
||||
<TOC title={title} headings={headings} type={type} mobile={true}/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,23 @@
|
|||
---
|
||||
import TableOfContents from "./toc";
|
||||
import type { ConfigHeading, TypeTOC } from "./types.d.ts";
|
||||
import type { TypeData } from "@config/io/types";
|
||||
|
||||
export interface Props {
|
||||
title?: string;
|
||||
headings?: ConfigHeading[];
|
||||
types?: TypeTOC;
|
||||
type?: TypeData;
|
||||
mobile: boolean;
|
||||
}
|
||||
|
||||
const { title, headings, types, mobile } = Astro.props;
|
||||
const { title, headings, type, mobile } = Astro.props;
|
||||
|
||||
const types: TypeTOC | null = type ? {
|
||||
properties: Object.keys(type.properties ?? {}),
|
||||
functions: (type.functions ?? []).map(f => f.name),
|
||||
signals: Object.keys(type.signals ?? {}),
|
||||
variants: Object.keys(type.variants ?? {}),
|
||||
} : null;
|
||||
---
|
||||
{((headings?.length ?? 0) != 0 || types) &&
|
||||
<div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@ export interface Props {
|
|||
|
||||
const { currentRoute, currentModule, currentClass } = Astro.props;
|
||||
|
||||
import { getTypeData } from "@config/io/generateTypeData";
|
||||
import { groupRoutes } from "@config/io/helpers";
|
||||
import { getModulesData } from "@config/io/generateTypeData";
|
||||
import type { TreeEntry } from "./Tree.astro";
|
||||
import Tree from "./Tree.astro";
|
||||
import Link from "./Link.astro";
|
||||
import VersionSelector from "./VersionSelector.astro"
|
||||
|
||||
const routes = await getTypeData();
|
||||
const groupedRoutes = groupRoutes(routes);
|
||||
const modules = await getModulesData();
|
||||
|
||||
import { getCollection } from "astro:content";
|
||||
const guidePages = await getCollection("guide");
|
||||
|
|
@ -45,18 +43,16 @@ const types = {
|
|||
title: "Quickshell Types",
|
||||
link: "/docs/types",
|
||||
current: currentRoute?.startsWith("types") ?? false,
|
||||
entries: Object.entries(groupedRoutes.types).map(
|
||||
([module, items]) => ({
|
||||
title: module,
|
||||
link: `/docs/types/${module}`,
|
||||
current: currentModule === module,
|
||||
entries: items.map(type => ({
|
||||
title: type.name,
|
||||
link: `/docs/types/${module}/${type.name}`,
|
||||
current: currentClass === type.name,
|
||||
})),
|
||||
})
|
||||
),
|
||||
entries: modules.map(module => ({
|
||||
title: module.name,
|
||||
link: `/docs/types/${module.name}`,
|
||||
current: currentModule === module.name,
|
||||
entries: module.types.map(type => ({
|
||||
title: type.name,
|
||||
link: `/docs/types/${module.name}/${type.name}`,
|
||||
current: currentClass === type.name,
|
||||
}))
|
||||
}))
|
||||
};
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -4,22 +4,20 @@ import type {
|
|||
QMLTypeLinkObject,
|
||||
QuickshellProps,
|
||||
} from "@config/io/types";
|
||||
import { Tag, Flag } from "@icons";
|
||||
import { Tag } from "@icons";
|
||||
import TypeTitle from "./TypeTitle.astro";
|
||||
|
||||
import TypeDetails from "./TypeDetails.astro";
|
||||
|
||||
export interface Props {
|
||||
propsKeys: string[];
|
||||
propsData: QuickshellProps;
|
||||
props: QuickshellProps;
|
||||
}
|
||||
|
||||
const { propsKeys, propsData } = Astro.props;
|
||||
const { props } = Astro.props;
|
||||
---
|
||||
<ul class="typedata typeprops">
|
||||
{
|
||||
propsKeys.map(item => {
|
||||
const propData = propsData[item]
|
||||
Object.entries(props).map(([name, propData]) => {
|
||||
let typeLink:string;
|
||||
let linkText:string;
|
||||
let genericType:string|undefined;
|
||||
|
|
@ -37,10 +35,10 @@ const { propsKeys, propsData } = Astro.props;
|
|||
genericTypeLink = getQMLTypeLink(propData.type.of)
|
||||
}
|
||||
return (
|
||||
<li id={ item } class="typedata-root typeprop-root">
|
||||
<li id={ name } class="typedata-root typeprop-root">
|
||||
<TypeTitle
|
||||
typekind="prop"
|
||||
typename={item}
|
||||
typename={name}
|
||||
typelink={typeLink}
|
||||
typelink_text={linkText}
|
||||
typename_generic={genericType}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,28 @@
|
|||
---
|
||||
import type { QuickshellSignal } from "@config/io/types";
|
||||
import { Tag, PowerCord } from "@icons";
|
||||
import { Tag } from "@icons";
|
||||
import TypeDetails from "./TypeDetails.astro";
|
||||
import TypeTitle from "./TypeTitle.astro";
|
||||
|
||||
export interface Props {
|
||||
signalKeys: string[];
|
||||
signalsData: QuickshellSignal;
|
||||
signals: QuickshellSignal;
|
||||
}
|
||||
|
||||
const { signalKeys, signalsData } = Astro.props;
|
||||
const { signals } = Astro.props;
|
||||
---
|
||||
<ul class="typedata typesignals">
|
||||
{
|
||||
signalKeys.map(item => {
|
||||
const signalData = signalsData[item];
|
||||
Object.entries(signals).map(([name, signalData]) => {
|
||||
const paramKeys = signalData.params.length > 0 ? signalData.params.map((param,index) => `${param.name}${index !== signalData.params.length -1 ? ", ":""}`) : []
|
||||
let genericType:string|undefined;
|
||||
let genericTypeLink:string|undefined;
|
||||
return (
|
||||
<li id={ item } class="typedata-root typesignal-root">
|
||||
<li id={ name } class="typedata-root typesignal-root">
|
||||
<TypeTitle
|
||||
typekind="signal"
|
||||
typename={item}
|
||||
typename={name}
|
||||
typelink="/docs/configuration/qml-overview#-signals"
|
||||
typelink_text={"?"}
|
||||
typelink_text=""
|
||||
typename_generic={genericType}
|
||||
typelink_generic={genericTypeLink}
|
||||
typedata_params={paramKeys}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,25 @@
|
|||
---
|
||||
import type { QuickshellVariant } from "@config/io/types";
|
||||
import { FourDiamonds } from "../icons";
|
||||
import TypeDetails from "./TypeDetails.astro";
|
||||
import TypeTitle from "./TypeTitle.astro";
|
||||
|
||||
export interface Props {
|
||||
variantKeys: string[];
|
||||
variantsData: QuickshellVariant;
|
||||
variants: QuickshellVariant;
|
||||
}
|
||||
|
||||
const { variantKeys, variantsData } = Astro.props;
|
||||
const { variants } = Astro.props;
|
||||
---
|
||||
<ul class="typedata typevariants">
|
||||
{
|
||||
variantKeys.map(item => {
|
||||
const variantData = variantsData[item];
|
||||
Object.entries(variants).map(([name, variantData]) => {
|
||||
const paramKeys = variantData.params && variantData.params.length > 0
|
||||
? variantData.params.map(param => param.name)
|
||||
: [];
|
||||
return (
|
||||
<li id={ item } class="typedata-root typevariant-root">
|
||||
<li id={ name } class="typedata-root typevariant-root">
|
||||
<TypeTitle
|
||||
typekind="variant"
|
||||
typename={item}
|
||||
typename={name}
|
||||
typelink=""
|
||||
typelink_text=""
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue