Skip to content

Commit

Permalink
feat: 统一多个组件的边框半径以提升样式一致性
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jan 16, 2025
1 parent 3810f77 commit 3cbc9da
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/MarkdownEditor/editor/elements/LinkCard/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const genStyle: GenerateStyle<ChatTokenType> = (token) => {
'&-container': {
padding: 12,
border: '1px solid #f0f0f0',
borderRadius: '1.2px',
borderRadius: '0.5em',
margin: '8px 0',
width: '100%',
maxHeight: '120px',
Expand Down
2 changes: 1 addition & 1 deletion src/MarkdownEditor/editor/elements/chart/ChartRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export const ChartRender: React.FC<{
margin: 12,
overflow: 'auto',
border: '1px solid #eee',
borderRadius: '1.2em',
borderRadius: '0.5em',
flex: 1,
maxWidth: 'calc(100% - 32px)',
maxHeight: 400,
Expand Down
6 changes: 3 additions & 3 deletions src/MarkdownEditor/editor/elements/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const Chart: React.FC<RenderElementProps> = (props) => {
style={{
display: 'flex',
flexDirection: 'column',
borderRadius: '1.2em',
borderRadius: '0.5em',
overflow: 'auto',
}}
>
Expand Down Expand Up @@ -411,7 +411,7 @@ export const Chart: React.FC<RenderElementProps> = (props) => {
key={index + subIndex}
style={{
border: '1px solid #eee',
borderRadius: '1.2em',
borderRadius: '0.5em',
margin: 'auto',
minWidth: `calc(${100 / columnLength}% - 16px)`,
flex: 1,
Expand All @@ -431,7 +431,7 @@ export const Chart: React.FC<RenderElementProps> = (props) => {
style={{
userSelect: 'none',
border: '1px solid #eee',
borderRadius: '1.2em',
borderRadius: '0.5em',
margin: 'auto',
minWidth: `calc(${100 / columnLength}% - 16px)`,
flex: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/MarkdownEditor/editor/elements/code/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const genStyle: GenerateStyle<ChatTokenType> = (token) => {
},
},
'& &-code-content': {
borderRadius: '1.2px',
borderRadius: '0.5em',
fontSize: '0.85em',
boxSizing: 'border-box',
lineHeight: '1.62em',
Expand Down
6 changes: 3 additions & 3 deletions src/MarkdownEditor/editor/elements/description/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ const genStyle: GenerateStyle<ChatTokenType> = (token) => {
[token.componentCls]: {
maxWidth: '100%',
overflow: 'auto',
borderRadius: '1.2px',
borderRadius: '0.5em',
border: '1px solid rgb(232, 232, 232)',
table: {
'& th': {
padding: '12px 20px',
textAlign: 'left',
fontWeight: 500,
border: '1px solid rgb(232, 232, 232)',
borderRadius: '1.2px',
borderRadius: '0.5em',
},
'& td': {
padding: '12px 20px',
textAlign: 'left',
border: '1px solid rgb(232, 232, 232)',
borderRadius: '1.2px',
borderRadius: '0.5em',
},
'& tr': {
'td:first-child': {
Expand Down
2 changes: 1 addition & 1 deletion src/MarkdownEditor/editor/elements/media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function Media({
style={{
padding: 12,
border: '1px solid #f0f0f0',
borderRadius: '1.2px',
borderRadius: '0.5em',
width: '100%',
backgroundImage:
'linear-gradient(rgb(249, 251, 255) 0%, rgb(243, 248, 255) 100%)',
Expand Down
13 changes: 12 additions & 1 deletion src/MarkdownEditor/editor/elements/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { useEditorStore } from '../store';
import { DragHandle } from '../tools/DragHandle';
import { TableAttr } from '../tools/TableAttr';

const numberValidationRegex = /^[+-]?(\d|([1-9]\d+))(\.\d+)?$/;

/**
* TableCell 组件用于渲染表格单元格,根据元素的 title 属性决定渲染 <th> 或 <td>。
*
Expand Down Expand Up @@ -101,6 +103,9 @@ export function TableCell(props: RenderElementProps) {
WebkitBoxOrient: 'vertical',
WebkitLineClamp: 2,
maxHeight: 40,
textAlign: numberValidationRegex.test(text?.replaceAll(',', ''))
? 'right'
: undefined,
}}
>
{text}
Expand All @@ -112,6 +117,12 @@ export function TableCell(props: RenderElementProps) {
minWidth: minWidth,
textWrap: 'wrap',
maxWidth: '200px',
display: 'flex',
justifyContent: numberValidationRegex.test(
text?.replaceAll(',', ''),
)
? 'end'
: 'start',
}}
>
{props.children}
Expand Down Expand Up @@ -332,7 +343,7 @@ export const Table = observer((props: RenderElementProps) => {
maxWidth: '100%',
width: '100%',
border: '1px solid #e8e8e8',
borderRadius: '1.2px',
borderRadius: '0.5em',
display: 'flex',
minWidth: 0,
boxShadow:
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEditor/editor/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ const genSlideStyle: GenerateStyle<ChatTokenType> = (token) => {
borderRight: 'none',
},
'th:last-child': {
borderTopRightRadius: 16,
borderTopRightRadius: '0.5em',
},
'th:first-child': {
borderTopLeftRadius: 16,
borderTopLeftRadius: '0.5em',
},
'tr:last-child th,tr:last-child td': {
borderBottom: 'none',
Expand Down
4 changes: 2 additions & 2 deletions src/MarkdownEditor/editor/tools/ToolBar/toolBarStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
const genStyle: GenerateStyle<ChatTokenType> = (token) => {
return {
[token.componentCls]: {
borderTopLeftRadius: '16px',
borderTopRightRadius: '16px',
borderTopLeftRadius: '0.5em',
borderTopRightRadius: '0.5em',
borderBottom: '1px solid rgb(229 231 235 / 0.8)',
overflow: 'hidden',
height: '42px',
Expand Down

1 comment on commit 3cbc9da

@vercel
Copy link

@vercel vercel bot commented on 3cbc9da Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.