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

feat(text): optimize vis-text margin #66

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/yellow-pumas-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/gpt-vis': patch
---

feat(text): optimize vis-text margin
10 changes: 8 additions & 2 deletions src/Text/VisText.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { Tooltip, Typography } from 'antd';
import { pick, toString } from 'lodash';
import React from 'react';
import styled from 'styled-components';
import { useComponentGlobalConfig } from '../ConfigProvider/hooks';
import { type TextConfig, STATICS_KEY } from './config';
import type { VisTextProps } from './types';
import { getThemeColor, useAntdDarkAlgorithm } from './utils';

const { Text } = Typography;

const StyledText = styled(Text)`
margin-left: 1px;
margin-right: 1px;
`;

function renderPrefixSuffix(
symbol: string,
staticsConfig: TextConfig[typeof STATICS_KEY],
Expand All @@ -31,7 +37,7 @@ const VisText = (props: VisTextProps) => {
return (
// TODO @羽熙 暂时简单处理 tooltip 直接显示 origin,后续可以根据 origin 类型分类处理
<Tooltip title={toString(origin)}>
<Text
<StyledText
className={className}
style={{
// antd Text 组件写死了 14px,在段落定义了 font-size 的情况下,显示很突兀,这里不设置,跟随上级容器字体大小改变。
Expand All @@ -45,7 +51,7 @@ const VisText = (props: VisTextProps) => {
{renderPrefixSuffix(encoding?.prefix, staticsConfig, props)}
{children}
{renderPrefixSuffix(encoding?.suffix, staticsConfig, props)}
</Text>
</StyledText>
</Tooltip>
);
};
Expand Down
Loading