Skip to content

Commit

Permalink
Merge pull request #117 from subquery/feat/new-typograph
Browse files Browse the repository at this point in the history
feat: new typography
  • Loading branch information
HuberTRoy authored Aug 23, 2024
2 parents 3536825 + 46554e1 commit 8a1c8ce
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 33 deletions.
4 changes: 2 additions & 2 deletions components/common/chatUi/chatUi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FiUser, FiSend } from 'react-icons/fi';
import { RiRobot2Line } from 'react-icons/ri';
import { AiFillApi } from 'react-icons/ai';
import { Button, Input, InputRef, message } from 'antd';
import localforage from 'localforage';
// import localforage from 'localforage';
import { Typography } from '../typography';
import { v4 as uuidv4 } from 'uuid';
import { cloneDeep, isString } from 'lodash-es';
Expand Down Expand Up @@ -453,7 +453,7 @@ export const ChatUi: FC<ChatUiProps> = ({ chatUrl, prompt, className, placeholde
const filtered = chats.filter((c) => c.id !== item.id);
setChats(filtered);
setCurrentChat(filtered[0]);
await localforage.setItem(workspaceName, filtered);
// await localforage.setItem(workspaceName, filtered);
}}
></ConversationItem>
);
Expand Down
29 changes: 15 additions & 14 deletions components/common/typography/Typography.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,44 @@

&__h1 {
font-family: var(--sq-font-family-header);
font-size: 80px;
line-height: 100px;
font-size: 160px;
line-height: 128px;
letter-spacing: -0.04em;
}

&__h2 {
font-family: var(--sq-font-family-header);
font-size: 60px;
line-height: 88px;
font-size: 80px;
line-height: 72px;
}

&__h3 {
font-family: var(--sq-font-family-header);
font-size: 48px;
line-height: 64px;
font-size: 32px;
line-height: 29px;
}

&__h4 {
font-weight: bold;
font-size: 32px;
line-height: 48px;
font-size: 24px;
line-height: 26px;
}

&__h5 {
font-weight: 500;
font-size: 24px;
line-height: 36px;
font-size: 20px;
line-height: 24px;
}

&__h6 {
font-weight: 500;
font-size: 20px;
line-height: 30px;
line-height: 24px;
}

&__large {
font-size: 18px;
line-height: 28px;
line-height: 24px;
}

&__text {
Expand Down Expand Up @@ -141,7 +142,7 @@
color: #fff;

&.subql-typography__secondary {
color: var(--sq-gray400);
color: rgba(255,255,255,0.6);
}
}

Expand Down
42 changes: 33 additions & 9 deletions components/common/typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import * as React from 'react';
import clsx from 'clsx';
import './Typography.less';
import { Space, Tooltip } from 'antd';
import { Tooltip } from 'antd';
import { createBEM } from 'components/utilities/createBem';
import { Context } from '../provider';
import { attachPropertiesToComponent } from 'components/utilities/attachPropertiesToCompnent';
import { useMemo } from 'react';

export type TypographProps = {
variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'large' | 'text' | 'medium' | 'small' | 'overline';
Expand All @@ -17,8 +18,24 @@ export type TypographProps = {
className?: string;
tooltipIcon?: React.ReactNode;
disabled?: boolean;
center?: boolean;
maxWidth?: string | number | undefined;
} & React.HTMLProps<HTMLParagraphElement>;

const componentsName: { [key in string]: keyof JSX.IntrinsicElements } = {
h1: 'h1',
h2: 'h2',
h3: 'h3',
h4: 'h4',
h5: 'h5',
h6: 'h6',
large: 'article',
text: 'article',
medium: 'article',
small: 'article',
overline: 'article',
};

export interface LinkProps extends TypographProps {
href?: string;
children?: React.ReactNode;
Expand All @@ -38,12 +55,20 @@ const TypographyInner: React.FC<TypographProps> = ({
tooltipIcon,
className,
disabled,
center,
style,
width,
maxWidth,
color,
...htmlProps
}) => {
const Component = useMemo<keyof JSX.IntrinsicElements>(() => componentsName[variant], [variant]);
const { theme } = React.useContext(Context);

const inner = () => (
<article
// TODO: fix this type
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<Component
{...htmlProps}
className={clsx(
bem(),
Expand All @@ -54,20 +79,19 @@ const TypographyInner: React.FC<TypographProps> = ({
bem({ disabled }),
className,
)}
style={{ textAlign: center ? 'center' : undefined, width, maxWidth, color, ...style }}
>
{children}
</article>
</Component>
);
if (!tooltip) {
return <Space>{inner()}</Space>;
return inner();
}
return (
<Tooltip title={tooltip} placement="topLeft" className={tooltip && clsx(bem({ tooltip: 'tooltip' }))}>
<Space className={clsx(bem({ space: 'space' }))}>
{inner()}
{inner()}

{tooltipIcon}
</Space>
{tooltipIcon}
</Tooltip>
);
};
Expand Down
30 changes: 22 additions & 8 deletions components/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
--sq-primary-card-deephover: #e968dd66;
--sq-primary-link-hover: #d25ec7;

--sq-primary-pink: #ff4581;
--sq-primary-blue: #1677ff;
--sq-gradient: linear-gradient(96.26deg, var(--sq-primary-blue) 13.8%, var(--sq-primary-pink) 82.83%);
--sq-background-gradient: linear-gradient(
96.26deg,
rgba(var(--sq-primary-blue-rgb), 0.08) 13.8%,
rgba(var(--sq-primary-pink-rgb), 0.08) 82.83%
);
--sq-primary-pink: #e968dd;
--sq-primary-blue: #385ce5;
--sq-primary-green: #1bdfbd;
--sq-primary-orange: #ffb21d;
--sq-gradient: linear-gradient(96.5deg, #ffffff 57.69%, #a7dee5 89.18%),
linear-gradient(142.44deg, #f7cdf2 3.83%, #ffffff 35.89%, #ffffff 72.52%, #a7dee5 95.42%),
linear-gradient(0deg, var(--Gray-white, #ffffff), var(--Gray-white, #ffffff)),
linear-gradient(180.56deg, #f094e8 -11.03%, #ffffff 55%, #ffffff 130.46%, #a7dee5 177.62%);

--sq-background-gradient: linear-gradient(180deg, #ffffff 47%, #e968dd 64.5%, #385ce5 85.5%);

/* Blue */
--sq-blue100: #a1c4ee;
Expand Down Expand Up @@ -59,6 +61,18 @@
--sq-gray900: #1a202c;
--sq-graylight: #c2c9d1;

/* --sq-gray100: #E6E6E6;
--sq-gray200: #CCCCCC;
--sq-gray300: #B3B3B3;
--sq-gray400: #808080;
--sq-gray500: #666666;
--sq-gray600: #4D4D4D;
--sq-gray700: #333333;
--sq-gray800: #1a1a1a;
--sq-gray900: #000000; */

--sq-white: #ffffff;

/* Semantic */
--sq-success: #65cd45;
--sq-warning: #f87c4f;
Expand Down

0 comments on commit 8a1c8ce

Please sign in to comment.