Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea6cf69
feat/1870: add design guideline content for button page
twjeffery May 14, 2024
aedc3ec
chore: allow to add github link and updated date to component header
vanessatran-ddi Jun 4, 2024
89a72a0
Add figma link
vanessatran-ddi Jun 6, 2024
7e942b4
remove improve this component section
vanessatran-ddi Jun 6, 2024
77eac14
chore: remove colon from "last updated on"
twjeffery Jun 6, 2024
719a1f9
remove border for iframe
vanessatran-ddi Jun 6, 2024
4a1f4fb
Merge remote-tracking branch 'origin/twjeffery-patch-4' into twjeffer…
vanessatran-ddi Jun 6, 2024
6d2560e
update component's related to body-s text
vanessatran-ddi Jun 6, 2024
c79c744
update font-size for span under component header
vanessatran-ddi Jun 7, 2024
03137ba
chore: do/dont container height
twjeffery Jun 11, 2024
2765c84
chore: height fix for do/dont container
twjeffery Jun 11, 2024
3583254
chore: height fix for do/dont container
twjeffery Jun 11, 2024
d82d55b
chore: fix height for do/dont
twjeffery Jun 11, 2024
ea79c6b
Add files via upload
twjeffery Jun 11, 2024
22aa0c3
chore: content update
twjeffery Jun 11, 2024
55dce80
chore: content update
twjeffery Jun 11, 2024
791c7b6
chore: content update
twjeffery Jun 11, 2024
6078c19
chore: content update
twjeffery Jun 11, 2024
e2dcdca
Add files via upload
twjeffery Jun 11, 2024
672347c
Add files via upload
twjeffery Jun 11, 2024
19c32e2
Chore: content-update
twjeffery Jun 11, 2024
05fd34a
chore: content update
twjeffery Jun 11, 2024
5d54518
chore: update do and don'ts styling
twjeffery Jun 11, 2024
96c3146
chore: content update
twjeffery Jun 11, 2024
3a2614f
chore: spacing update to component header
twjeffery Jun 11, 2024
b292c9d
chore: content update
twjeffery Jun 11, 2024
84b8a29
chore: content update
twjeffery Jun 11, 2024
27f1570
chore: Content update
twjeffery Jun 11, 2024
570b085
chore: example update
twjeffery Jun 11, 2024
36723b3
chore: content test
twjeffery Jun 11, 2024
de160c8
chore: undo content change
twjeffery Jun 11, 2024
7485ec9
chore: content update
twjeffery Jun 11, 2024
5534294
chore: content update
twjeffery Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@abgov/react-components": "4.17.0-alpha.25",
"@abgov/web-components": "1.17.0-alpha.51",
"@faker-js/faker": "^8.3.1",
"date-fns": "^3.6.0",
"highlight.js": "^11.8.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/components/button/do-image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions src/components/component-header/ComponentHeader.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
.component-header {
margin-bottom: 3rem;
margin-top: 2rem;
margin-bottom: var(--goa-space-l);
margin-top: var(--goa-space-xl);
}

.component-header h1 {
margin-bottom: 1rem;
margin-top: 1.5rem;
margin-bottom: var(--goa-space-m);
margin-top: var(--goa-space-l);
}

.component-header h3 {
margin-bottom: var(--goa-space-xs);
}

.component-header span.small,
.component-header a.small {
font: var(--goa-typography-body-s);
}
.component-header span.x-small,
.component-header a.x-small {
font: var(--goa-typography-body-xs);
}

@media screen and (max-width: 623px) {
Expand Down
59 changes: 51 additions & 8 deletions src/components/component-header/ComponentHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { GoABadge } from "@abgov/react-components";
import { GoABadge, GoABlock } from "@abgov/react-components";
import "./ComponentHeader.css";
import { Link } from "react-router-dom";

import { format } from 'date-fns';
import { useEffect, useState } from "react";

interface Props {
category?: Category;
name: string;
description?: string;
relatedComponents?: { link: string; name: string }[];
githubLink?: string;
}

export enum Category {
Expand All @@ -19,23 +21,64 @@ export enum Category {
}

export const ComponentHeader: React.FC<Props> = (props: Props) => {
const GITHUB_BASE = "https://github.com/GovAlta/ui-components-docs/blob/main/src/";
const [lastUpdateTime, setLastUpdateTime] = useState<Date | null>(null);
useEffect(() => {
if (props.githubLink) {
const fetchLastUpdateTime = async () => {
try {
const url = `https://api.github.com/repos/GovAlta/ui-components-docs/commits?path=src/${props.githubLink}`;
const response = await fetch(url);
if (!response.ok) {
return;
}
const commits = await response.json();
if (commits.length === 0) {
return;
}
const lastCommit = commits[0];
const lastUpdateTime = new Date(lastCommit.commit.committer.date);
setLastUpdateTime(lastUpdateTime);
} catch (error) {
console.error((error as Error).message);
}
};

fetchLastUpdateTime();
}
}, [props.githubLink]);

return (
<div className="component-header">
<GoABadge type="information" content={props.category} />
<h1>{props.name}</h1>
<h2 id="component" className="hidden" aria-hidden="true">Component</h2>
<h3 dangerouslySetInnerHTML={{__html: props.description || ''}}></h3>
<h2 id="component" className="hidden" aria-hidden="true">
Component
</h2>
<h3 dangerouslySetInnerHTML={{ __html: props.description || "" }}></h3>

{props.relatedComponents?.length && (
<>
<span>Related components: </span>
<GoABlock mb={"l"} gap={"xs"}>
<span className="small">Related: </span>
{props.relatedComponents.map((relatedComponent, index, array) => (
<span key={index}>
<span className="small" key={index}>
<Link to={relatedComponent.link}>{relatedComponent.name}</Link>
{index < array.length - 1 && ", "}
</span>
))}
</>
</GoABlock>
)}
{props.githubLink && (
<GoABlock gap="xs">
{lastUpdateTime && (
<span className={"x-small greyscale"}>
Last updated on {format(lastUpdateTime, "MMM dd, yyyy")}
</span>
)}
<a className={"x-small"} href={`${GITHUB_BASE}${props.githubLink}`} target="_blank">
Edit this page
</a>
</GoABlock>
)}
</div>
);
Expand Down
8 changes: 6 additions & 2 deletions src/components/do-dont/DoDont.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.do-container {
font-size: var(--goa-font-size-5);
border: var(--goa-border-width-s) solid var(--goa-color-greyscale-200);
padding: 3rem;
padding: var(--goa-space-2xl);
}

.do-container:has(> iframe),
.do-container:has(> img) {
padding: 0;
}
.description {
font: var(--goa-typography-body-s);
font: var(--goa-typography-body-m);
}
.description.type-generic{
margin-top: var(--goa-space-m);
Expand Down
21 changes: 18 additions & 3 deletions src/components/do-dont/DoDont.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@ import { ReactNode } from "react";
type DoDont = "do" | "dont" | "generic";
interface Props {
type: DoDont;
children: ReactNode;
children?: ReactNode;
description?: string;
figmaLink?: string;
}

export function DoDont({ type, children, description }: Props) {
export function DoDont({ type, children, description, figmaLink }: Props) {
return (
<div>
<div className="do-container">{children}</div>
<div className="do-container">
{figmaLink ? (
<a href={figmaLink} target="_blank" rel="noopener noreferrer">
<div className="figma-preview">
<img
src={`https://www.figma.com/embed?embed_host=share&url=${figmaLink}`}
alt="Figma Preview"
style={{ width: '100%', height: 'auto' }}
/>
</div>
</a>
) : (
children
)}
</div>
{(type === "do" || type === "dont") && (
<div className="do-content" data-positive={type}>
{type === "do" ? <GoAIcon type="checkmark-circle" /> : <GoAIcon type="close-circle" />}
Expand Down
2 changes: 1 addition & 1 deletion src/examples/task-list-page/TaskListPageExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function TaskListPageExamples() {
</GoATable>

<h3>3. Schedule service</h3>
<p className="small">
<p className="small text-secondary">
You need to complete the previous section before you can start this task.
</p>
<GoATable width="100%" mt="l" mb="3xl">
Expand Down
Loading