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

DM-48448: Add link to user docs from Times Square UI #173

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions apps/squareone/squareone.config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"title": "Base URL for the public ingress",
"description": "Used for computing absolute URLs"
},
"docsBaseUrl": {
"type": "string",
"default": "https://rsp.lsst.io",
"title": "Base URL for the user documentation site.",
"description": "Used for computing URLs for user documentation pages for this RSP instance. The default is for the public RSP. For USDF, use `https://rsp.lsst.io/v/usdfprod`. Does not end in /."
},
"semaphoreUrl": {
"type": "string",
"title": "Semaphore URL",
Expand Down
1 change: 1 addition & 0 deletions apps/squareone/squareone.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ siteName: 'Squareone Development Site'
baseUrl: 'http://localhost:3000'
siteDescription: |
The site description.
docsBaseUrl: 'https://rsp.lsst.io'
semaphoreUrl: 'https://data-dev.lsst.cloud/semaphore'
timesSquareUrl: 'http://localhost:3000/times-square/api'
coManageRegistryUrl: 'https://id.lsst.cloud'
Expand Down
15 changes: 15 additions & 0 deletions apps/squareone/src/components/TimesSquareApp/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

import Link from 'next/link';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { IconPill } from '@lsst-sqre/squared';

import { getDocsUrl } from '../../lib/utils/docsUrls';

const StyledSidebar = styled.div`
border-right: 1px solid var(--rsd-color-primary-600);
Expand All @@ -21,6 +26,8 @@ const AppTitle = styled.p`
`;

export default function Sidebar({ pageNav, pagePanel }) {
const docsUrl = getDocsUrl('/guides/times-square/index.html');

return (
<StyledSidebar>
<Link href="/times-square">
Expand All @@ -29,6 +36,14 @@ export default function Sidebar({ pageNav, pagePanel }) {
</a>
</Link>

<IconPill
icon={['fas', 'book']}
text="Documentation"
url={docsUrl}
textColor="#ffffff"
backgroundColor="var(--rsd-color-primary-600)"
/>

{pagePanel && pagePanel}

{pageNav && pageNav}
Expand Down
11 changes: 11 additions & 0 deletions apps/squareone/src/lib/utils/docsUrls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import getConfig from 'next/config';

/**
* Get the full URL to a documentation page.
* @param path The path to the documentation page, starting with "/"
* @returns The full URL to the documentation page
*/
export function getDocsUrl(path) {
const { publicRuntimeConfig } = getConfig();
return `${publicRuntimeConfig.docsBaseUrl}${path}`;
}
2 changes: 2 additions & 0 deletions apps/squareone/src/styles/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
faCircleMinus,
faCodeCommit,
faDownload,
faBook,
} from '@fortawesome/free-solid-svg-icons';
import { faGithub } from '@fortawesome/free-brands-svg-icons';

Expand All @@ -27,4 +28,5 @@ library.add(faCircleCheck);
library.add(faCircleMinus);
library.add(faCodeCommit);
library.add(faDownload);
library.add(faBook);
library.add(faGithub);
3 changes: 3 additions & 0 deletions packages/squared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
},
"dependencies": {
"@fontsource/source-sans-pro": "^4.5.11",
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.2",
"@lsst-sqre/global-css": "workspace:*",
"@lsst-sqre/rubin-style-dictionary": "workspace:*",
"@radix-ui/react-dropdown-menu": "^2.0.5",
Expand Down
43 changes: 43 additions & 0 deletions packages/squared/src/components/IconPill/IconPill.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Meta, StoryObj } from '@storybook/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconPill } from './IconPill';

import { library } from '@fortawesome/fontawesome-svg-core';
import { faBook } from '@fortawesome/free-solid-svg-icons';

// Add icons to the global Font Awesome library
library.add(faBook);

const meta: Meta<typeof IconPill> = {
title: 'Components/IconPill',
component: IconPill,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof IconPill>;

export const Default: Story = {
args: {
icon: ['fas', 'book'],
text: 'Documentation',
url: '#',
textColor: '#ffffff',
backgroundColor: '#000000',
},

render: ({ icon, text, url, textColor, backgroundColor }) => {
return (
<IconPill
icon={icon}
text={text}
url={url}
textColor={textColor}
backgroundColor={backgroundColor}
/>
);
},
};
59 changes: 59 additions & 0 deletions packages/squared/src/components/IconPill/IconPill.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconPrefix, IconName } from '@fortawesome/fontawesome-svg-core';

export interface IconPillProps {
text: string;
url: string;
icon: [IconPrefix, IconName];
backgroundColor?: string;
textColor?: string;
}

const PillContainer = styled.span<{
backgroundColor: string;
textColor: string;
}>`
display: inline-block;
padding: 2px 10px;
border-radius: 0.5em;
color: ${(props) => props.textColor};
background-color: ${(props) => props.backgroundColor};
font-size: 0.9rem;
font-weight: 700;

a {
text-decoration: none;
color: inherit;
}

&:hover {
box-shadow: 0 10px 15px -10px rgba(22, 23, 24, 0.35);
}
`;

const StyledFontAwesomeIcon = styled(FontAwesomeIcon)`
display: inline-block;
margin-right: 0.4em;
font-size: 0.9em;
`;

export const IconPill: React.FC<IconPillProps> = ({
icon,
text,
url,
backgroundColor = '#e0e0e0',
textColor = '#000000',
}) => {
return (
<PillContainer backgroundColor={backgroundColor} textColor={textColor}>
<a href={url}>
<StyledFontAwesomeIcon icon={icon} />
{text}
</a>
</PillContainer>
);
};

export default IconPill;
2 changes: 2 additions & 0 deletions packages/squared/src/components/IconPill/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './IconPill';
export { default } from './IconPill';
1 change: 1 addition & 0 deletions packages/squared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
default as GafaelfawrUserMenu,
type GafaelfawrUserMenuProps,
} from './components/GafaelfawrUserMenu';
export { default as IconPill, type IconPillProps } from './components/IconPill';

/* Hooks */
export { default as useCurrentUrl } from './hooks/useCurrentUrl';
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading