Skip to content

Commit 42f0313

Browse files
committed
refactor(#194): made some changes on the font stylings
1 parent 6e99152 commit 42f0313

File tree

7 files changed

+25
-12
lines changed

7 files changed

+25
-12
lines changed

lib/@dsvgui/components/article/index.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const Article: React.FC<IArticle> = ({ articles }) => {
3232
const titleWidth =
3333
Math.max(
3434
...articles.map((article) =>
35-
getTextWidth(article.meta.title, { fontSize: 16, fontWeight: 700 })
35+
getTextWidth(article.meta.title, { fontSize: 16, fontWeight: 500 })
3636
),
3737
400
3838
) + 20;
@@ -52,9 +52,9 @@ export const Article: React.FC<IArticle> = ({ articles }) => {
5252

5353
const title = wrapText(
5454
article.meta.title,
55-
{ maxLineWidth: titleWidth, fontSize: 16, fontWeight: 700 },
55+
{ maxLineWidth: titleWidth, fontSize: 16, fontWeight: 500 },
5656
(line: string, index: number) => (
57-
<Text x={0} y={index * 25} option={{ size: 16, weight: 700 }}>
57+
<Text x={0} y={index * 25} option={{ size: 16, weight: 500 }}>
5858
{line}
5959
</Text>
6060
)
@@ -85,8 +85,9 @@ export const Article: React.FC<IArticle> = ({ articles }) => {
8585
(line: string, index) => (
8686
<Text
8787
x={0}
88-
y={20 + title.length + index * 13}
88+
y={17 + title.length + index * 13}
8989
option={{ size: 12, weight: 500 }}
90+
className="subtitle"
9091
>
9192
{line}
9293
</Text>

lib/@dsvgui/components/barstats/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const BarStats: React.FC<IBarStats> = ({
8686
size: 14,
8787
weight: 500,
8888
}}
89+
className="subtitle"
8990
>
9091
{`${item.name} %${(
9192
(item.value / totalValue) *

lib/@dsvgui/components/flock/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Flock: React.FC<IFlock> = ({
3535
};
3636

3737
const titleWidth = title
38-
? getTextWidth(title.trim(), { fontSize: titleFontSize, fontWeight: 700 })
38+
? getTextWidth(title.trim(), { fontSize: titleFontSize, fontWeight: 500 })
3939
: 0;
4040
const subtitleWidth = subtitle
4141
? getTextWidth(subtitle.trim(), {

lib/@dsvgui/components/metrics/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const Metrics: React.FC<IMetrics> = ({ data, icon: Icon }) => {
5555
<Text x={xText} y={10} option="subtitle">
5656
{item.title}
5757
</Text>
58-
<Text x={xText} y={33.51} option={{ size: 22, weight: 700 }}>
58+
<Text x={xText} y={33.51} option={{ size: 22, weight: 500 }}>
5959
{item.value.toString()}
6060
</Text>
6161
{index !== 0 && (

lib/@dsvgui/document/branding.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ type IBranding = {
77

88
export const Branding: React.FC<IBranding> = ({ x, y }) => {
99
return (
10-
<Text x={x} y={y} option={{ size: 8, weight: 500 }}>
10+
<Text
11+
x={x}
12+
y={y}
13+
option={{ size: 8, weight: 500 }}
14+
id="dsvguibranding"
15+
className="text"
16+
>
1117
readme.rocks
1218
</Text>
1319
);

lib/@dsvgui/document/style.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ export const Style: React.FC = () => {
33
<defs>
44
<style>{`
55
.websafe{ font-family: Tahoma, Verdana, sans-serif }
6-
.text{ fill: #32373e;}
7-
.text.subtitle{ fill: #5c5c5c; }
6+
.text{ fill: #22272e;}
7+
.text.subtitle{ fill: #6c6c6c; }
88
99
.dsvgui-container{ fill: #fbfbfb; }
1010
stop[offset='0']{ stop-color: #fbfbfb; }

lib/@dsvgui/document/text.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ type IText = {
1414
option: IFontType | IFontOptions;
1515
children: string | number | undefined;
1616
as?: "path" | "text";
17+
className?: string;
18+
id?: string;
1719
};
1820

1921
const onHandFonts = {
2022
title: {
2123
size: 22,
22-
weight: 700,
24+
weight: 500,
2325
},
2426
subtitle: {
2527
size: 16,
@@ -33,6 +35,8 @@ export const Text: React.FC<IText> = ({
3335
option,
3436
children,
3537
as = "text",
38+
className = " ",
39+
id,
3640
}) => {
3741
if (!children) return <></>;
3842
const defaultFontFamily = defaultFont;
@@ -47,18 +51,19 @@ export const Text: React.FC<IText> = ({
4751
if (typeof x === "function")
4852
x = x(openTypeFont.getAdvanceWidth(children.toString(), font.size));
4953

50-
const classNames = ["text"];
54+
const classNames = ["text", className];
5155
if (typeof option === "string") classNames.push(option);
5256

5357
if (as === "path") {
5458
const path = openTypeFont.getPath(children.toString(), x, y, font.size);
5559
const pathSVG = path.toPathData(1);
5660

57-
return <path className={classNames.join(" ")} d={pathSVG} />;
61+
return <path id={id} className={classNames.join(" ")} d={pathSVG} />;
5862
} else {
5963
classNames.push("websafe");
6064
return (
6165
<text
66+
id={id}
6267
x={x}
6368
y={y}
6469
className={classNames.join(" ")}

0 commit comments

Comments
 (0)