Skip to content

Commit

Permalink
refactor: _typeMark -> typeMark
Browse files Browse the repository at this point in the history
  • Loading branch information
联民 committed Oct 11, 2022
1 parent 1aeaac4 commit 778d80e
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ RefBlock.defaultProps = {
mode: 'surface',
noPadding: false,
};
RefBlock._typeMark = 'Block';
RefBlock.typeMark = 'Block';

export default RefBlock;
2 changes: 1 addition & 1 deletion src/cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ RefCell.defaultProps = {
block: false,
direction: 'ver',
};
RefCell._typeMark = 'Cell';
RefCell.typeMark = 'Cell';

export default RefCell;
2 changes: 1 addition & 1 deletion src/col.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ const Col: ForwardRefRenderFunction<HTMLDivElement, ColProps> = (props, ref) =>
const RefCol: ICol = forwardRef(Col);

RefCol.displayName = 'Col';
RefCol._typeMark = 'Col';
RefCol.typeMark = 'Col';

export default RefCol;
2 changes: 1 addition & 1 deletion src/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const Grid: ForwardRefRenderFunction<HTMLDivElement, GridProps> = (props, ref) =
const RefGrid: IGrid = forwardRef(Grid);

RefGrid.displayName = 'Grid';
RefGrid._typeMark = 'Grid';
RefGrid.typeMark = 'Grid';
RefGrid.defaultProps = {
rows: 1,
cols: 1,
Expand Down
4 changes: 2 additions & 2 deletions src/p.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const getChildren = (children: any, type: ParagraphProps['type'] = 'body2') => {
</Text>,
);
// @ts-ignore
} else if (child.type._typeMark === 'Text' && !child.props.type) {
} else if (child.type.typeMark === 'Text' && !child.props.type) {
return cloneElement(child, {
type,
});
Expand Down Expand Up @@ -101,7 +101,7 @@ const P: ForwardRefRenderFunction<HTMLParagraphElement, ParagraphProps> = (props
const RefParagraph: IParagraph = forwardRef(P);

RefParagraph.displayName = 'P';
RefParagraph._typeMark = 'P';
RefParagraph.typeMark = 'P';

RefParagraph.defaultProps = {
spacing: 'medium',
Expand Down
2 changes: 1 addition & 1 deletion src/page/aside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ PageAside.defaultProps = {
width: 200,
mode: 'transparent',
};
PageAside._typeMark = 'Aside';
PageAside.typeMark = 'Aside';

export default PageAside;
4 changes: 2 additions & 2 deletions src/page/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const PageContent: ForwardRefRenderFunction<any, PageContentProps> = (

if (isValidElement(child)) {
// @ts-ignore
tm = child?.type?._typeMark;
tm = child?.type?.typeMark;

if (tm === 'Nav') {
navNode = child;
Expand Down Expand Up @@ -125,6 +125,6 @@ const PageContent: ForwardRefRenderFunction<any, PageContentProps> = (
const RefPageContent: IPageContent = forwardRef(PageContent);

RefPageContent.displayName = 'PageContent';
RefPageContent._typeMark = 'Content';
RefPageContent.typeMark = 'Content';

export default RefPageContent;
2 changes: 1 addition & 1 deletion src/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const Page: ForwardRefRenderFunction<any, PageProps> = (props, ref) => {
const tmp = Children.map(children, (child) => {
if (isValidElement(child)) {
// @ts-ignore
const tm = child?.type?._typeMark;
const tm = child?.type?.typeMark;

if (tm) {
if (tm === 'Header') {
Expand Down
2 changes: 1 addition & 1 deletion src/page/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ PageNav.defaultProps = {
width: 200,
mode: 'transparent',
};
PageNav._typeMark = 'Nav';
PageNav.typeMark = 'Nav';

export default PageNav;
2 changes: 1 addition & 1 deletion src/page/page-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ PageFooter.defaultProps = {
fullWidth: false,
mode: 'surface',
};
PageFooter._typeMark = 'Footer';
PageFooter.typeMark = 'Footer';

export default PageFooter;
2 changes: 1 addition & 1 deletion src/page/page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ PageHeader.defaultProps = {
mode: 'surface',
};

PageHeader._typeMark = 'Header';
PageHeader.typeMark = 'Header';

export default PageHeader;
2 changes: 1 addition & 1 deletion src/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ const Row: ForwardRefRenderFunction<HTMLDivElement, RowProps> = (props, ref) =>
const RefRow: IRow = forwardRef(Row);

RefRow.displayName = 'Row';
RefRow._typeMark = 'Row';
RefRow.typeMark = 'Row';

export default RefRow;
4 changes: 2 additions & 2 deletions src/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function wrapBlock(children: ReactNode, maxNumberOfColumns: number) {
const validChildList = Children.toArray(children).filter((child) => !isNil(child));

validChildList.forEach((child: any, index) => {
if (child?.type === Block || child?.type?._typeMark === 'Block') {
if (child?.type === Block || child?.type?.typeMark === 'Block') {
if (tmp.length > 0) {
ret.push(
<Block key={`cs-${index}`} span={maxNumberOfColumns}>
Expand Down Expand Up @@ -243,6 +243,6 @@ const Section: ForwardRefRenderFunction<HTMLDivElement, SectionProps> = (props,

const RefSection: ISection = forwardRef(Section);
RefSection.displayName = 'Section';
RefSection._typeMark = 'Section';
RefSection.typeMark = 'Section';

export default RefSection;
2 changes: 1 addition & 1 deletion src/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Text: ITextComponent = (props) => {
};

Text.displayName = 'Text';
Text._typeMark = 'Text';
Text.typeMark = 'Text';
Text.defaultProps = {
align: 'left',
type: 'body2',
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface BaseBgMode {
}

export interface TypeMark {
_typeMark?: string;
typeMark?: string;
}

/**
Expand Down

0 comments on commit 778d80e

Please sign in to comment.