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

Typography support collapse #47264

Merged
merged 42 commits into from Mar 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0a4eb49
feat: typograohy support collapse
crazyair Jan 31, 2024
73b0c6b
feat: snap
crazyair Jan 31, 2024
49f3c54
feat: test
crazyair Jan 31, 2024
d37781d
feat: 单测不符合预期
crazyair Feb 1, 2024
be364e1
feat: test
crazyair Feb 1, 2024
fab54d1
feat: 恢复
crazyair Feb 2, 2024
e862e85
feat: md
crazyair Feb 2, 2024
b1d244e
feat: test
crazyair Feb 2, 2024
e84c968
feat: test
crazyair Feb 2, 2024
4f5e2d6
feat: 修改命名
crazyair Feb 2, 2024
9a96d8c
feat: 代码优化
crazyair Feb 2, 2024
e0e198d
feat: 添加控制台提示
crazyair Feb 2, 2024
684f9b1
feat: snap
crazyair Feb 3, 2024
9931b91
Merge remote-tracking branch 'origin/feature' into add-collapse
crazyair Feb 6, 2024
16716f4
feat: symbol support function
crazyair Feb 6, 2024
f752275
feat: snap
crazyair Feb 6, 2024
62fd637
fix: text
crazyair Feb 6, 2024
2bb2202
feat: snap
crazyair Feb 6, 2024
6d78b72
feat: api 修改
crazyair Feb 6, 2024
627a093
feat: key 修改
crazyair Feb 6, 2024
df1dec3
feat: 去掉参数
crazyair Feb 6, 2024
b23e772
feat: lint
crazyair Feb 6, 2024
bae69ce
feat: snap
crazyair Feb 6, 2024
804ef17
Merge remote-tracking branch 'origin/feature' into add-collapse
crazyair Feb 20, 2024
4271a47
Merge remote-tracking branch 'origin/feature' into add-collapse
crazyair Feb 22, 2024
b723382
feat: merge feature
crazyair Mar 1, 2024
5eb32b2
Merge remote-tracking branch 'origin/feature' into add-collapse
crazyair Mar 1, 2024
d535008
Merge remote-tracking branch 'origin/feature' into add-collapse
crazyair Mar 15, 2024
a5015ed
feat: test
crazyair Mar 16, 2024
d65c421
Merge remote-tracking branch 'origin/feature' into add-collapse
crazyair Mar 16, 2024
1652c68
feat: use 2
crazyair Mar 16, 2024
8f69f85
feat: review
crazyair Mar 16, 2024
d746ce3
feat: test
crazyair Mar 16, 2024
f95252a
Merge remote-tracking branch 'origin/feature' into add-collapse
zombieJ Mar 18, 2024
c674e44
chore: part of it
zombieJ Mar 18, 2024
7d31dbf
chore: fix auto collapse logic
zombieJ Mar 18, 2024
2a4c903
feat: 修改 doc 单测
crazyair Mar 18, 2024
d3c8632
feat: doc
crazyair Mar 18, 2024
9a253c4
test: update testcase
zombieJ Mar 19, 2024
6227a1f
Merge branch 'feature' into add-collapse
crazyair Mar 19, 2024
13cd2da
docs: add more
zombieJ Mar 19, 2024
d5066c2
Merge branch 'add-collapse' of https://github.com/ant-design/ant-desi…
zombieJ Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 6 additions & 9 deletions components/typography/Base/index.tsx
Expand Up @@ -238,13 +238,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
const [isJsEllipsis, setIsJsEllipsis] = React.useState(false);
const [isNativeEllipsis, setIsNativeEllipsis] = React.useState(false);
const [isNativeVisible, setIsNativeVisible] = React.useState(true);
const [enableEllipsis, ellipsisConfig] = useMergedConfig<EllipsisConfig>(ellipsis, {
expandable: false,
symbol: textLocale.expand,
expand: textLocale.expand,
collapsible: false,
collapse: textLocale.collapse,
});
const [enableEllipsis, ellipsisConfig] = useMergedConfig<EllipsisConfig>(ellipsis, {});

const mergedEnableEllipsis = enableEllipsis && !expanded;

Expand Down Expand Up @@ -412,9 +406,12 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
// Expand
const renderExpand = (renderExpanded: boolean) => {
const { expandable, symbol, expand, collapsible, collapse } = ellipsisConfig;
const _expand = expand ?? symbol;
if (!expandable) return null;
if (!collapsible && !renderExpanded) return null;

const _expand = expand ?? symbol ?? textLocale.expand;
crazyair marked this conversation as resolved.
Show resolved Hide resolved
const _collapse = collapse ?? textLocale.collapse;

const key = renderExpanded ? 'expand' : 'collapse';
return (
<a
Expand All @@ -423,7 +420,7 @@ const Base = React.forwardRef<HTMLElement, BlockProps>((props, ref) => {
onClick={(e) => onExpandClick(e, renderExpanded)}
crazyair marked this conversation as resolved.
Show resolved Hide resolved
aria-label={renderExpanded ? textLocale?.expand : textLocale?.collapse}
zombieJ marked this conversation as resolved.
Show resolved Hide resolved
>
{renderExpanded ? _expand : collapse}
{renderExpanded ? _expand : _collapse}
</a>
);
};
Expand Down