diff --git a/packages/docs/components/index.md b/packages/docs/components/index.md
index 57fdd85b..5a639ac6 100644
--- a/packages/docs/components/index.md
+++ b/packages/docs/components/index.md
@@ -5,34 +5,32 @@
const { theme: { value: {sidebar } } } = useData();
const components = sidebar['/components/'];
+ const categories = import.meta.glob('./*/index.md', { eager: true });
+ const mod = import.meta.glob(`./*/*/index.md`, { eager: true });
+
+ const sections = Object.values(categories).map((md) => {
+ const { title, relativePath } = md.__pageData;
+ const sectionPath = relativePath.replace(/\/index\.md$/, '/');
+ const components = Object.fromEntries(Object.entries(mod).filter(([,{ __pageData }]) => {
+ return __pageData.filePath.startsWith(sectionPath)
+ }));
+
+ return {
+ title,
+ href: `/${sectionPath}`,
+ components,
+ }
+ });
Components are grouped following the [Atomic Design principles](https://bradfrost.com/blog/post/atomic-web-design/) with an extra `Primitives` group containing components that are not directly usable but should be used to create other components.
-
-
+
-## Primitives
+## {{ section.title }}
-
-
+
+
+
-## Atoms
-
-
-
-
-## Molecules
-
-
-
-
-## Organisms
-
-
-
diff --git a/packages/docs/components/molecules/Accordion/index.md b/packages/docs/components/molecules/Accordion/index.md
index 46c9945b..1cf6e70f 100644
--- a/packages/docs/components/molecules/Accordion/index.md
+++ b/packages/docs/components/molecules/Accordion/index.md
@@ -1,9 +1,8 @@
-# Accordion
+---
+badges: [Twig, JS]
+---
-
+# Accordion
## Table of content
diff --git a/packages/docs/components/molecules/MapboxStaticMap/index.md b/packages/docs/components/molecules/MapboxStaticMap/index.md
index 8c93552b..f8fdc217 100644
--- a/packages/docs/components/molecules/MapboxStaticMap/index.md
+++ b/packages/docs/components/molecules/MapboxStaticMap/index.md
@@ -1,12 +1,10 @@
-# MapboxStaticMap
+---
+badges: [Twig]
+---
-The `MapboxStaticMap` component can be used to display custom maps anywhere, without having to load the full Mapbox GL JavaScript library. You can test all features from this API on the [static images API playground](https://docs.mapbox.com/playground/static/) from Mapbox.
-
-
+The `MapboxStaticMap` component can be used to display custom maps anywhere, without having to load the full Mapbox GL JavaScript library. You can test all features from this API on the [static images API playground](https://docs.mapbox.com/playground/static/) from Mapbox.
## Table of content
diff --git a/packages/docs/components/molecules/Menu/index.md b/packages/docs/components/molecules/Menu/index.md
index a8631255..38b5869c 100644
--- a/packages/docs/components/molecules/Menu/index.md
+++ b/packages/docs/components/molecules/Menu/index.md
@@ -1,9 +1,8 @@
-# Menu (todo)
+---
+badges: [JS]
+---
-
+# Menu (todo)
## Table of content
diff --git a/packages/docs/components/molecules/Modal/index.md b/packages/docs/components/molecules/Modal/index.md
index 4bb49b63..d561100b 100644
--- a/packages/docs/components/molecules/Modal/index.md
+++ b/packages/docs/components/molecules/Modal/index.md
@@ -1,9 +1,8 @@
-# Modal (todo)
+---
+badges: [Twig, JS]
+---
-
+# Modal (todo)
## Table of content
diff --git a/packages/docs/components/molecules/Panel/index.md b/packages/docs/components/molecules/Panel/index.md
index 013b17d9..86693d30 100644
--- a/packages/docs/components/molecules/Panel/index.md
+++ b/packages/docs/components/molecules/Panel/index.md
@@ -1,9 +1,8 @@
-# Panel (todo)
+---
+badges: [Twig, JS]
+---
-
+# Panel (todo)
## Table of content
diff --git a/packages/docs/components/molecules/TableOfContent/index.md b/packages/docs/components/molecules/TableOfContent/index.md
index 3fae118c..f0ad05e8 100644
--- a/packages/docs/components/molecules/TableOfContent/index.md
+++ b/packages/docs/components/molecules/TableOfContent/index.md
@@ -1,10 +1,8 @@
-# TableOfContent (todo)
+---
+badges: [JS, deprecated]
+---
-
+# TableOfContent (todo)
## Table of content
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 005bdc8f..dfe89adb 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui-docs",
- "version": "0.2.46",
+ "version": "0.2.47",
"private": true,
"type": "module",
"scripts": {
@@ -11,21 +11,20 @@
"build": "vitepress build ."
},
"dependencies": {
- "@studiometa/js-toolkit": "^2.11.2"
+ "@studiometa/js-toolkit": "^2.12.0"
},
"devDependencies": {
- "@iconify-json/octicon": "^1.1.49",
+ "@iconify-json/octicon": "^1.1.52",
"@studiometa/playground": "^0.0.3",
"@studiometa/tailwind-config": "^1.1.0",
- "@studiometa/ui-shared": "*",
"@vueuse/components": "^10.9.0",
"@vueuse/core": "^10.9.0",
- "autoprefixer": "^10.4.16",
+ "autoprefixer": "^10.4.19",
"concurrently": "^8.2.2",
"snake-case": "^3.0.4",
- "tailwindcss": "^3.3.3",
+ "tailwindcss": "^3.4.1",
"unplugin-icons": "^0.15.3",
"unplugin-vue-components": "^0.22.12",
- "vitepress": "^1.0.0-rc.42"
+ "vitepress": "^1.0.1"
}
}
diff --git a/packages/playground/package.json b/packages/playground/package.json
index 511c7d01..98e06a73 100644
--- a/packages/playground/package.json
+++ b/packages/playground/package.json
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui-playground",
- "version": "0.2.46",
+ "version": "0.2.47",
"private": true,
"type": "module",
"scripts": {
diff --git a/packages/tests/__snapshots__/index.spec.js.snap b/packages/tests/__snapshots__/index.spec.js.snap
index 495dbc8a..b86de746 100644
--- a/packages/tests/__snapshots__/index.spec.js.snap
+++ b/packages/tests/__snapshots__/index.spec.js.snap
@@ -49,6 +49,7 @@ exports[`components exports 1`] = `
"Transition",
"animationScrollWithEase",
"loadImage",
+ "withDeprecation",
"withTransition",
]
`;
diff --git a/packages/tests/molecules/Accordion/AccordionItem.spec.js b/packages/tests/molecules/Accordion/AccordionItem.spec.js
index d852fbd6..be2f727d 100644
--- a/packages/tests/molecules/Accordion/AccordionItem.spec.js
+++ b/packages/tests/molecules/Accordion/AccordionItem.spec.js
@@ -21,7 +21,7 @@ describe('AccordionItem component', () => {
class AccordionItemWithIcon extends AccordionItem {
static config = {
- ...(AccordionItem.config || {}),
+ ...AccordionItem.config,
refs: [...AccordionItem.config.refs, 'icon'],
};
}
diff --git a/packages/tests/package.json b/packages/tests/package.json
index 5d8be8de..ce638986 100644
--- a/packages/tests/package.json
+++ b/packages/tests/package.json
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui-tests",
- "version": "0.2.46",
+ "version": "0.2.47",
"private": true,
"type": "module",
"scripts": {
diff --git a/packages/ui/decorators/index.ts b/packages/ui/decorators/index.ts
index 8a0e4141..c1c2cc82 100644
--- a/packages/ui/decorators/index.ts
+++ b/packages/ui/decorators/index.ts
@@ -1,2 +1,2 @@
-// eslint-disable-next-line import/prefer-default-export
export * from './withTransition.js';
+export * from './withDeprecation.js';
diff --git a/packages/ui/decorators/withDeprecation.ts b/packages/ui/decorators/withDeprecation.ts
new file mode 100644
index 00000000..e8de2bfb
--- /dev/null
+++ b/packages/ui/decorators/withDeprecation.ts
@@ -0,0 +1,44 @@
+import type {
+ Base,
+ BaseDecorator,
+ BaseProps,
+ BaseConfig,
+ BaseInterface,
+} from '@studiometa/js-toolkit';
+import { isDev } from '@studiometa/js-toolkit/utils';
+
+export interface DeprecationProps extends BaseProps {}
+
+export interface DeprecationInterface extends BaseInterface {}
+
+/**
+ * Mark a class a deprecated.
+ */
+export function withDeprecation(
+ BaseClass: typeof Base,
+ message?: string,
+): BaseDecorator {
+ /**
+ * Class.
+ */
+ class Deprecated extends BaseClass {
+ /**
+ * Config.
+ */
+ static config: BaseConfig = {
+ name: 'Deprecated',
+ };
+
+ onMounted() {
+ if (isDev) {
+ console.warn(
+ `The ${this.$options.name} component is deprecated.`,
+ message ? `\n${message}` : '',
+ );
+ }
+ }
+ }
+
+ // @ts-ignore
+ return Deprecated;
+}
diff --git a/packages/ui/molecules/TableOfContent/TableOfContent.ts b/packages/ui/molecules/TableOfContent/TableOfContent.ts
index 06fccd44..ac422ec8 100644
--- a/packages/ui/molecules/TableOfContent/TableOfContent.ts
+++ b/packages/ui/molecules/TableOfContent/TableOfContent.ts
@@ -1,6 +1,7 @@
import { Base } from '@studiometa/js-toolkit';
import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
import { TableOfContentAnchor } from './TableOfContentAnchor.js';
+import { withDeprecation } from '../../decorators/withDeprecation.js';
export interface TableOfContentProps extends BaseProps {
$refs: {
@@ -18,8 +19,11 @@ export interface TableOfContentProps extends BaseProps {
/**
* TableOfContent class.
+ * @deprecated
*/
-export class TableOfContent extends Base {
+export class TableOfContent extends withDeprecation(Base)<
+ T & TableOfContentProps
+> {
/**
* Config.
*/
diff --git a/packages/ui/molecules/TableOfContent/TableOfContentAnchor.ts b/packages/ui/molecules/TableOfContent/TableOfContentAnchor.ts
index 769b4381..b64e5076 100644
--- a/packages/ui/molecules/TableOfContent/TableOfContentAnchor.ts
+++ b/packages/ui/molecules/TableOfContent/TableOfContentAnchor.ts
@@ -1,5 +1,6 @@
import type { BaseProps, BaseConfig } from '@studiometa/js-toolkit';
import { AnchorScrollTo } from '../../atoms/index.js';
+import { withDeprecation } from '../../decorators/withDeprecation.js';
export interface TableOfContentAnchorProps extends BaseProps {
$options: {
@@ -9,10 +10,11 @@ export interface TableOfContentAnchorProps extends BaseProps {
/**
* TableOfContentAnchor class.
+ * @deprecated
*/
-export class TableOfContentAnchor extends AnchorScrollTo<
- T & TableOfContentAnchorProps
-> {
+export class TableOfContentAnchor extends withDeprecation(
+ AnchorScrollTo,
+) {
/**
* Config.
*/
@@ -52,7 +54,7 @@ export class TableOfContentAnchor extends Ancho
const shouldActivate =
entry.isIntersecting &&
entry.boundingClientRect.y < 100 &&
- entry.boundingClientRect.y > 100;
+ entry.boundingClientRect.y > -100;
this.$el.classList.toggle(this.$options.activeClass, shouldActivate);
this.$emit('should-activate', shouldActivate);
});
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 8b3aa1b4..4e1625f5 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui",
- "version": "0.2.46",
+ "version": "0.2.47",
"description": "A set of opiniated, unstyled and accessible components",
"publishConfig": {
"access": "public"
@@ -29,7 +29,7 @@
},
"homepage": "https://github.com/studiometa/ui#readme",
"dependencies": {
- "@studiometa/js-toolkit": "^2.10.2",
- "deepmerge": "^4.2.2"
+ "@studiometa/js-toolkit": "^2.12.0",
+ "deepmerge": "^4.3.1"
}
}