Skip to content

Commit 0e3e725

Browse files
thomasheartmannicolaesocaciusighphyre
authored
docs: add "The Anatomy of Unleash" (#2138)
## What This PR 1. adds a new topic document, "The Anatomy of Unleash", which explains how Unleash is built up as a system. 2. It also moves the "topic guides" sidebar entry from position 4 to position 2. 3. Finally, it introduces a new `Figure` component for the documentation, to be used with images that should be shown with captions. ## Why Referring to the same numbers as mentioned above, here's some background for these changes: 1. We have gotten requests from enterprise users for a way to help new Unleash users understand the system. Together with customer success and customer journey, we agreed that an explanatory guide would be suitable. It aims to give the reader an introduction into what pieces constitute the Unleash system. 2. As part of a discussion, it was suggested to move topic guides higher up to make them more visible. There's a few reasons for this: 1. New users of Unleash should be able to keep reading about Unleash after the basic introductory material. When left at the bottom, topic guides are often overlooked 2. As a justification, it was proposed that reference docs are often the last thing you look for, so it makes sense to put that last. 3. Thinking about a new user's flow, it also makes some sense: first read introductory material, then dive deeper into what Unleash is and what you can use it for, then look for how-to guides if you're stuck, and finally consult the reference material for later. 3. These diagrams aren't necessarily very self-explanatory, so adding a caption makes a lot of sense. We didn't have a component from this previously, so I added one. Co-authored-by: NicolaeUnleash <[email protected]> Co-authored-by: Simon Hornby <[email protected]> ## Commits * docs: add raw export of anatomy document * docs: move the topic guides section to near top of sidebar * docs: add inter-doc links, some reformatting * docs: fix broken links * docs: add a Figure element for figures with captions * docs: add more styling to figures * docs: align on styles * Fix: add fuller figure caption * docs: rephrase heading * Docs(test): try new way of importing images * Docs(test): images take 3 * docs: Convert all images to using the figure component * docs: add projects to list of top-level resources * docs: add captions for all figures. * docs: reorder images * Docs(fix): typo: extra brackets * Docs(style): remove box shadows and border on fig caption images * Docs(chore): remove commented-out css * Docs(refactor): use css variable for small font size. To facilitate reusability and convey meaning. * docs: rename anatomy doc * docs: add note about strategies vs constraints * Updating the images * Apply suggestions from code review Co-authored-by: Simon Hornby <[email protected]> * Update website/docs/topics/the-anatomy-of-unleash.mdx * Docs(fix): remove redundant comma * docs: add link to node js sdk * docs: mention that a toggle must be active in an env to be enabled * docs: add note about environments and api keys * Docs(reword): swap dev and prod in example * docs: fix typo in the image * docs: make figures in text full-width * docs: move environments and API keys call-out to after figure * docs: add borders to figures * docs: add image float css idea * Revert "docs: add image float css idea" This reverts commit 69f27d3. Co-authored-by: NicolaeUnleash <[email protected]> Co-authored-by: Simon Hornby <[email protected]>
1 parent b0626d4 commit 0e3e725

16 files changed

+364
-13
lines changed

website/docs/topics/the-anatomy-of-unleash.mdx

Lines changed: 202 additions & 0 deletions
Large diffs are not rendered by default.

website/sidebars.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ module.exports = {
2828
'user_guide/quickstart',
2929
],
3030
},
31+
{
32+
label: 'Topic guides',
33+
collapsed: false,
34+
type: 'category',
35+
link: {
36+
type: 'generated-index',
37+
title: 'Topic guides',
38+
description:
39+
'Discussions, explanations, and explorations regarding topics related to Unleash.',
40+
slug: '/topics',
41+
},
42+
items: [
43+
'topics/the-anatomy-of-unleash',
44+
'topics/a-b-testing',
45+
'topics/proxy-hosting',
46+
],
47+
},
3148
{
3249
label: 'How-to guides',
3350
collapsed: false,
@@ -305,18 +322,5 @@ module.exports = {
305322
},
306323
],
307324
},
308-
{
309-
label: 'Topic guides',
310-
collapsed: false,
311-
type: 'category',
312-
link: {
313-
type: 'generated-index',
314-
title: 'Topic guides',
315-
description:
316-
'Discussions, explanations, and explorations regarding topics related to Unleash.',
317-
slug: '/topics',
318-
},
319-
items: ['topics/a-b-testing', 'topics/proxy-hosting'],
320-
},
321325
],
322326
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import Component from './Figure';
3+
import Layout from '@theme/Layout';
4+
import { BrowserRouter } from 'react-router-dom';
5+
6+
export default {
7+
title: 'Figure',
8+
component: Component,
9+
};
10+
11+
const Template = (args) => (
12+
<BrowserRouter>
13+
<Layout>
14+
<Component {...args} />
15+
</Layout>
16+
</BrowserRouter>
17+
);
18+
19+
export const WithCaption = Template.bind({});
20+
WithCaption.args = {
21+
img: '/img/anatomy-of-unleash-constraint.png',
22+
caption: 'This explanatory caption is visible to everyone.',
23+
};
24+
25+
export const WithCaptionAndAlt = Template.bind({});
26+
WithCaption.args = {
27+
img: '/img/anatomy-of-unleash-constraint.png',
28+
caption: 'This explanatory caption is visible to everyone.',
29+
alt: "This alt text is read out by screen readers and displayed if the image doesn't load",
30+
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
This component displays a figure with an accompanying figure caption. Use it
3+
to display diagrams, charts, and other images that have an explanatory
4+
caption that should be visible to everyone.
5+
6+
For some info regarding alt text vs fig captions, see this stack overflow
7+
response from a blind user (available at
8+
https://stackoverflow.com/questions/58447538/accessibility-difference-between-img-alt-and-figcaption):
9+
10+
I'm a blind user. I would say that there are two big categories of images on the web:
11+
12+
1. Functional images
13+
2. Illustrative images a.k.a. figures
14+
15+
AS the name says, figcaption is a caption for a figure. The caption is
16+
always visible by everybody, not only blind people. Figures are images that
17+
can be found in a book, an article, or whatever more or less long paragraphs
18+
of text. Most of the time, figures are purely illustrative.
19+
20+
When you use figcaption, the alt attribute should probably be empty:
21+
22+
- Copying the text of the figcaption into the alt attribute, or any
23+
shortened version, is almost always useless: the screen reader will read
24+
twice the same or almost the same information, and it's worth absolutely
25+
nothing
26+
27+
- You may think that the alt attribute could be useful for a longer
28+
description of the image, that wouldn't fit in the figcaption; for example
29+
a detailed description of a chart or a diagram. But in fact, this kind of
30+
description is better below the image or in another page (then available
31+
for everybody), rather than in the alt attribute. The alt attribute should
32+
normally remain short.
33+
34+
- You may think that the figcaption is useless and only set the alt
35+
attribute to something. Example: "Photo with Alice on the left, Bob on the
36+
right". But in fact sighted people could as well find this information
37+
useful, if they don't know Alice and Bob for example. So it could be
38+
interesting to move this description to the figcaption, so that everybody
39+
benefits from it and not only blind people.
40+
41+
Now, the biggest case when you won't use figure/figcaption is when images
42+
are functional: a button taht can be clicked, an icon with a precise
43+
meaning, etc. The basic rules for alt texts of functional images are:
44+
45+
- If you can interact with the image to perform actions (click, etc.), or if
46+
the icon conveys an information, then you must set a non-empty alt. It
47+
must be a function description, not a objective description of the image.
48+
49+
Example 1: "Go back" is good, while "Blue left arrow" is bad.
50+
Example 2: "Unread message" is good, while "Closed enveloppe" is bad
51+
52+
- Otherwise, if the image provide no interaction and if it doesn't convey
53+
any information, then it is illustrative; the alt should be empty in that
54+
case.
55+
56+
------
57+
58+
However, even when using fig captions, there **may** be times when also
59+
using an alt is appropriate, which is why it's an optional attribute on
60+
this component. However, if you do use it, make sure it conveys
61+
**separate** information to what the fig caption does.
62+
63+
64+
**/
65+
66+
import React from 'react';
67+
import useBaseUrl from '@docusaurus/useBaseUrl';
68+
69+
import './styles.module.css';
70+
71+
type Props = {
72+
// An optional alt text, if the caption does not already convey all relevant
73+
// information.
74+
alt?: string;
75+
// The figure caption, visible to everyone
76+
caption: string;
77+
// the path to the image, starting with `/img/`. Example: /img/image.png
78+
img: string;
79+
};
80+
81+
const Component: React.FC<Props> = ({ img, alt, caption }) => {
82+
return (
83+
<figure>
84+
<img alt={alt} src={useBaseUrl(img)} />
85+
<figcaption>{caption}</figcaption>
86+
</figure>
87+
);
88+
};
89+
90+
export default Component;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Figures (with captions) */
2+
figure {
3+
box-shadow: var(--ifm-global-shadow-lw);
4+
border-radius: var(--ifm-global-radius);
5+
border: var(--ifm-global-border-width) solid var(--unleash-color-gray);
6+
padding: var(--ifm-pre-padding);
7+
margin-inline: 0;
8+
}
9+
10+
figure img {
11+
box-shadow: none;
12+
border: none;
13+
}
14+
15+
figure * + * {
16+
margin-block-start: var(--ifm-pre-padding);
17+
}
18+
19+
figcaption {
20+
font-size: var(--unleash-font-size-smaller);
21+
padding-inline: var(--ifm-pre-padding);
22+
border-inline-start: 5px solid var(--ifm-color-primary);
23+
}

website/src/css/custom.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
--ifm-code-font-size: 90%;
1414
--ifm-font-size-base: 15px;
1515
--navbar-link-color: #122d33;
16+
17+
--unleash-font-size-smaller: 90%;
1618
}
1719

1820
footer {
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)