Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(documentation): Set id/permalink for stories #2603

Merged
merged 15 commits into from
Feb 14, 2024

Conversation

imagoiq
Copy link
Contributor

@imagoiq imagoiq commented Feb 5, 2024

Set an id for each story as in https://storybook.js.org/docs/configure/sidebar-and-urls#permalink-to-stories. This allows to separate the URL generation from the display name. The URL is generated with the id and the name of the story with the title.
You can change the title without changing the id so we can keep a kind of permalink.

Most of id are duplicated from title, except for foundations.

@imagoiq imagoiq self-assigned this Feb 5, 2024
Copy link

changeset-bot bot commented Feb 5, 2024

⚠️ No Changeset found

Latest commit: 5711c31

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@imagoiq imagoiq linked an issue Feb 5, 2024 that may be closed by this pull request
@swisspost-bot
Copy link
Contributor

swisspost-bot commented Feb 5, 2024

Preview environment ready: https://preview-2603--swisspost-design-system-next.netlify.app

@imagoiq
Copy link
Contributor Author

imagoiq commented Feb 5, 2024

Those code smells have nothing do it with this PR, fixed in #2605

# Conflicts:
#	packages/documentation/src/stories/components/button-group/button-group.stories.ts
#	packages/documentation/src/stories/components/forms/textarea/textarea.stories.ts
Copy link
Contributor

@alizedebray alizedebray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! 👍

Can you just update the links to the foundation docs using the new id's?

Also, I'm not sure that using the titles as identifiers is the best solution because there will be discrepancies as soon as we update a component name... I would probably go for a unique id, maybe with an enum somewhere. What do you think?

@imagoiq
Copy link
Contributor Author

imagoiq commented Feb 7, 2024

This is great! 👍

Can you just update the links to the foundation docs using the new id's?

Good catch!

Also, I'm not sure that using the titles as identifiers is the best solution because there will be discrepancies as soon as we update a component name... I would probably go for a unique id, maybe with an enum somewhere. What do you think?

I think this is a timeless question between slug vs id/uuid. It can be one or another, or mixed. I'm not really fond of only uuid as it's not user-friendly (and a bit prone to security issue). Using a mix doesn't make it more permanent except if we say that the slug is only here for human (e.g. /bzasdh/accessibility) and is ignored in the redirect process, but this is not how Storybook works, and it doesn't allow that. I think we just should care of any changes and redirect path using a middleware. So it's debatable, perhaps we should have survey in the roundtable meeting?

@alizedebray
Copy link
Contributor

So it's debatable, perhaps we should have survey in the roundtable meeting?

Sure, let's talk about that with the team

@@ -29,7 +30,7 @@ export default meta;
// DECORATORS
function externalControls(story: StoryFn, context: StoryContext) {
const { args, canvasElement } = context;
const togglerId = `${context.id}--button`;
const togglerId = `button--${context.id}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid otherwise, as we are targetting an id starting with a number later.

@imagoiq
Copy link
Contributor Author

imagoiq commented Feb 8, 2024

It was decided on the roundtable to used exclusively uuid.

# Conflicts:
#	packages/documentation/src/stories/components/heading/heading.docs.mdx
#	packages/documentation/src/stories/foundation/typography/typography.docs.mdx
#	packages/documentation/src/stories/utilities/heading/heading.docs.mdx
#	packages/documentation/src/stories/utilities/heading/heading.stories.ts
Copy link

sonarcloud bot commented Feb 14, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@imagoiq imagoiq merged commit 3653fd6 into main Feb 14, 2024
8 checks passed
@imagoiq imagoiq deleted the feat/2465-docs-permalink branch February 14, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checks links rot with CI + have permalink
3 participants