Skip to content

Commit

Permalink
Merge pull request #8682 from guardian/mxdvl/island-descriptions
Browse files Browse the repository at this point in the history
Improve Islands descriptions
  • Loading branch information
mxdvl authored Aug 29, 2023
2 parents 141b51e + dd7a7fd commit 0d39666
Show file tree
Hide file tree
Showing 32 changed files with 144 additions and 51 deletions.
7 changes: 4 additions & 3 deletions dotcom-rendering/scripts/islands/island-descriptions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getRegExForIsland = (name) =>
'\n/\\*\\*\n?' +
'((?: \\*.*\n)+)' +
' \\*\\/' +
`\nexport const ${name} =`,
`\\s+export const ${name} =`,
'm',
);

Expand Down Expand Up @@ -112,10 +112,11 @@ const getIslands = async (report) => {
: '';

const description =
matched?.[1]
`# ${name.replaceAll(/([A-Z])/g, ' $1')}\n` +
(matched?.[1]
?.split('\n')
.map((jsdoc_line) => jsdoc_line.slice(3))
.join('\n') ?? `# ${name} \n No description yet… 😢`;
.join('\n') ?? `No description yet… 😢`);

const html = await processor.process(description);

Expand Down
10 changes: 7 additions & 3 deletions dotcom-rendering/src/components/AlreadyVisited.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { useEffect } from 'react';
import { incrementAlreadyVisited } from '../lib/alreadyVisited';

/**
* # AlreadyVisited
*
* Increment the already visited count.
*
* @returns {} _No visual or DOM output_
* ## Why does this need to be an Island?
*
* This modifies local storage values.
*
* ---
*
* Does not render **anything**.
*/
export const AlreadyVisited = () => {
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ type Props = {
};

/**
* # AudioAtomWrapper
* ## Why does this need to be an Island?
*
* The audio atom is interactive.
* Requires consent to use audio ads.
*
* ---
*
* (No visual story exists)
*/
export const AudioAtomWrapper = ({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ const labelStyles = css`
type Props = {
targetedTerritory: AustralianTerritory;
};

/**
* Allows containers targetted to a specific territory to be changed
* to a different territory. E.g New South Wales to Victoria
*
* ## Why does this need to be an Island?
*
* We use cookies to set the user’s territory.
*
* ---
*
* [`AustralianTerritorySwitcher` on Chromatic](https://www.chromatic.com/component?appId=63e251470cfbe61776b0ef19&csfId=components-australianterritoryswitcher--victoria&buildNumber=2967)
*/
export const AustralianTerritorySwitcher = ({ targetedTerritory }: Props) => {
const [expanded, setExpanded] = useState(false);

Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/Branding.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ type Props = {
};

/**
* # Branding
*
* Wrapper around the logo and link for sponsored or paid for content.
*
* ## Why does this need to be an Island?
Expand Down
8 changes: 8 additions & 0 deletions dotcom-rendering/src/components/BrazeMessaging.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ type Props = {
/**
* This component ensures we call buildBrazeMessaging at least once
* on every page
*
* ## Why does this need to be an Island?
*
* All behaviour is client-side.
*
* ---
*
* Does not render **anything**.
*/
export const BrazeMessaging = ({ idApiUrl }: Props) => {
const { brazeMessages, brazeCards } = useBraze(idApiUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const collapsibleCalloutStyle = css`
`;

/**
* # Callout Block Component
*
* A callout to readers to share their stories.
* This is the updated version of the CalloutEmbedBlockComponent.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ let hasFormBeenOpened = true;
type FormDataType = { [key in string]: unknown };

/**
* # Callout Embed Block Component
*
* A callout to readers to share their stories.
*
* ## Why does this need to be an Island?
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/Carousel.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,6 @@ const decideCarouselColours = (
};

/**
* # Carousel
*
* A carousel of cards, mainly used in onward journeys,
* at the bottom of articles
*
Expand Down
9 changes: 6 additions & 3 deletions dotcom-rendering/src/components/CommentCount.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ const linkStyles = css`
`;

/**
* # CommentCount
*
* Shows the number of comments at the top of an article.
*
* ## Why does this need to be an Island?
*
* Fetches the count from the discussion API.
*
* [Storybook `Count`](https://637e40d1bc73bf3f604394b9-rzazjyrwhc.chromatic.com/?path=/story/components-counts)
* ---
*
* [`Count` on Chromatic](https://www.chromatic.com/component?appId=63e251470cfbe61776b0ef19&csfId=components-counts&buildNumber=2967)
*/
export const CommentCount = ({
discussionApiUrl,
Expand Down
17 changes: 11 additions & 6 deletions dotcom-rendering/src/components/DiscussionContainer.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ import { Discussion } from './Discussion';
import { DiscussionWhenSignedIn } from './DiscussionWhenSignedIn';

/**
* DiscussionContainer
*
* A wrapper component that decides if the user is signed in or not.
*
* If they
* are, it renders DiscussionWhenSignedIn which includes an api call to fetch
* the user profile.
* If they are, it renders `DiscussionWhenSignedIn` which includes
* an API call to fetch the user profile.
*
* If not, it simply renders Discussion
* If not, it simply renders `Discussion`
*
* We use component composition like this here because you cannot call react
* hooks conditionally and we're using a hook to make the fetch request
*
* Note. We allow the ...props pattern here because it makes sense when we're
* just passing them through
*
* ## Why does this need to be an Island?
*
* Discussion has client-side interactivity.
* Signed-in status is only known on the client.
*
* ---
*
* (No visual story exist)
*/

export const DiscussionContainer = (props: DiscussionProps) => {
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/GetMatchNav.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type Props = {
const Loading = () => <Placeholder height={230} />;

/**
* # Get Match Nav
*
* Wrapper around `MatchNav` with loading and fallback.
*
* ## Why does this need to be an Island?
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/GetMatchStats.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export const cleanTeamData = (team: TeamType): TeamType => ({
});

/**
* # Get Match Stats
*
* Wrapper around `MatchStats`.
*
* ## Why does this need to be an Island?
Expand Down
9 changes: 9 additions & 0 deletions dotcom-rendering/src/components/GetMatchTabs.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ type Props = {

const Loading = () => <Placeholder height={40} />;

/**
* ## Why does this need to be an Island?
*
* Data is fetched from an API on the client-side.
*
* ---
*
* (No visual story exists)
*/
export const GetMatchTabs = ({ matchUrl, format }: Props) => {
const { data, error, loading } = useApi<{
reportUrl?: string;
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/HeaderTopBar.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ const topBarStylesFromLeftCol = css`
`;

/**
* # Header Top Bar
*
* The slim dark blue top bar at the very top of Guardian pages
*
* ## Why does this need to be an Island?
Expand Down
4 changes: 1 addition & 3 deletions dotcom-rendering/src/components/LatestLinks.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ const extractAboutThreeLines = (text: string) =>
.join(' ') + '…'; // join with spaces and add an ellipsis

/**
* # Latest Links
*
* Display the last three blocks from a Liveblog when the fronts
* tool has enabled showing live updates.
*
Expand All @@ -122,7 +120,7 @@ const extractAboutThreeLines = (text: string) =>
*
* ---
*
* [`LatestLinks` on Chromatic](https://www.chromatic.com/component?appId=63e251470cfbe61776b0ef19&csfId=components-latestlinks)
* [`LatestLinks` on Chromatic](https://www.chromatic.com/component?appId=63e251470cfbe61776b0ef19&csfId=components-latestlinks&buildNumber=2967)
*/
export const LatestLinks = ({
id,
Expand Down
8 changes: 8 additions & 0 deletions dotcom-rendering/src/components/LightboxHash.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import { useOnce } from '../lib/useOnce';
*
* If we didn't do this then you'd end up back where you were when you pasted the
* url into the browser and unable to access the article under the lightbox.
*
* ## Why does this need to be an Island?
*
* This behaviour is entirely client-side.
*
* ---
*
* Does not render **anything**.
*/
export const LightboxHash = () => {
useOnce(() => {
Expand Down
8 changes: 8 additions & 0 deletions dotcom-rendering/src/components/LiveBlogEpic.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ function insertAfter(referenceNode: HTMLElement, newNode: Element) {
* 2. Fetch - POST the payload to the contributions endpoint
* 3. Render - Take the url, props and name data we got in response to our fetch and dynamically import
* and render the Epic component using it
*
* ## Why does this need to be an Island?
*
* All behaviour is client-side.
*
* ---
*
* (No visual story exist)
*/
export const LiveBlogEpic = ({
sectionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ type Props = {
/**
* In the right hand column, there will be the right ad slot, followed
* by as many liveblog-right ad slots that can fit
*
* ## Why does this need to be an Island?
*
* Ads are rendered client-side.
*
* ---
*
* (No visual story exists)
*/
export const LiveblogRightMultipleAdSlots = ({
display,
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/Liveness.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ function getKey(
}

/**
* # Liveness
*
* Allow new blocks on live blogs to be added without page reload.
* Polls the content API inserts news blocks if the user
* is at the top of the article.
Expand Down
10 changes: 7 additions & 3 deletions dotcom-rendering/src/components/MostViewedFooter.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ const secondTierStyles = css`
`;

/**
* # Most Viewed Footer
*
* List of 10 most viewed articles to show at the bottom of pages.
*
* @Todo add Storybook link
* ## Why does this need to be an Island?
*
* Most viewed data if fetched client-side.
*
* ---
*
* (No visual story exists)
*/
export const MostViewedFooter = ({
tabs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ type Props = {
};

/**
* Wrapping MostViewedRight so we can determine whether or not there's enough vertical space in the container to render it
* Wrapping `MostViewedRight` so we can determine whether or not
* there's enough vertical space in the container to render it.
*
* ## Why does this need to be an Island?
*
* We may show the most viewed component depending on the length of the article,
* based on the computed height of the container.
*
* ---
*
* (No visual story exists)
*/
export const MostViewedRightWrapper = ({
componentDataAttribute,
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/OnwardsUpper.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ type Props = {
};

/**
* # Onwards Upper
*
* A wrapper around `Carousel` for showing related articles at the bottom
* of an article. This contains the logic around which articles to show,
* depending on a series of factors (story package, paid content, series tag, …)
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/PulsingDot.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ interface Props {
}

/**
* # Pulsing Dot
*
* Used for indicating an article is updating live
*
* ## Why does this need to be an Island?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ const buildUrl: (element: RichLinkBlockElement, ajaxUrl: string) => string = (
};

/**
* # Rich Link Component
*
* Wrapper around `RichLink` which fetches the rich links’ images.
*
* ## Why does this need to be an Island?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ const sendTracking = (
};

/**
* # Secure Signup iFrame
*
* A descendent of `EmailSignup` used to prevent users from entering their email
* on the same page as the one we run third-party scripts on.
*
Expand Down
2 changes: 0 additions & 2 deletions dotcom-rendering/src/components/SendAMessage.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ const summaryStyles = css`
`;

/**
* # Send a Message Component
*
* A callout for readers to get in touch with a liveblogger directly.
*
* ## Why does this need to be an Island?
Expand Down
11 changes: 11 additions & 0 deletions dotcom-rendering/src/components/SetABTests.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ type Props = {
pageIsSensitive: CoreAPIConfig['pageIsSensitive'];
};

/**
* Initialises the values of `useAB` and sends relevant Ophan events.
*
* ## Why does this need to be an Island?
*
* All this logic is client-side.
*
* ---
*
* Does not render **anything**.
*/
export const SetABTests = ({
isDev,
pageIsSensitive,
Expand Down
Loading

0 comments on commit 0d39666

Please sign in to comment.