frctl / fractal

A tool to help you build and document website component libraries and design systems.
https://fractal.build
MIT License
2.11k stars 170 forks source link

Allow custom information properties #624

Closed julkue closed 3 years ago

julkue commented 4 years ago

What problem would this feature solve?

Showing the semantic version out of package.json beside of the information when it was last built.

What the feature should look like?

Allow passing an object with freely defined key value pairs that will be shown together with builtOn. I would also think of replacing this with builtOn entirely (or only show it when the custom option is empty) since this would allow passing a custom builtOn with custom date formatter, e.g. "01.01.2020" instead of "01/01/2020".

Example:

fractal.web.theme(mandelbrot({
  skin: 'navy',
  panels: ['html', 'view', 'context', 'resources', 'notes'],
  favicon: '/images/common/favicon.ico',
  information: {
    'Version': pkg.version
  }
}));

For now I'm going to show the version in the project title:

fractal.set('project.title', `${pkg.description} <b><i style="color:#80a753">v${pkg.version}</i></b>`);
mihkeleidast commented 4 years ago

This would be nice and useful! Do you think we should only allow string information? The current builtOn renders a <time> element which should be better semantically. If we allowed strings, I could see feature requests to allow links etc too.

julkue commented 4 years ago

Of course numbers could be valid to, even dates when displayed using toLocaleDateString. But in the end, everything has to be converted to a string anyway, so I don't think it's a problem to expect a string.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.