Skip to content

Commit

Permalink
chore: using useTNodeJSX to render content
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Jun 19, 2024
1 parent 4c6a837 commit 960a87f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
18 changes: 11 additions & 7 deletions src/col/col.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { computed, defineComponent, CSSProperties, inject } from 'vue';
import { convertUnit } from '../shared';
import ColProps from './props';
import props from './props';
import config from '../config';
import { rowInjectionKey } from '../row/constants';
import { useTNodeJSX } from '../hooks/tnode';
import { usePrefixClass } from '../hooks/useClass';

const { prefix } = config;
const name = `${prefix}-col`;

export default defineComponent({
name,
props: ColProps,
setup(props, { slots }) {
props,
setup(props) {
const renderTNodeJSX = useTNodeJSX();
const componentName = usePrefixClass('col');
const { gutter } = inject(rowInjectionKey);

// 设置col gutter style
Expand All @@ -27,20 +31,20 @@ export default defineComponent({

// 设置col class
const colClass = computed(() => {
let colClass = `${prefix}-col`;
let colClass = componentName.value;
if (props.offset) {
colClass += ` ${prefix}-col--offset-${props.offset}`;
colClass += ` ${componentName.value}--offset-${props.offset}`;
}
if (props.span) {
colClass += ` ${prefix}-col--${props.span}`;
colClass += ` ${componentName.value}--${props.span}`;
}
return colClass;
});

return () => {
return (
<div class={colClass.value} style={style.value}>
{slots.default?.()}
{renderTNodeJSX('default')}
</div>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/col/demos/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
import BaseDemo from './base.vue';
import OffsetDemo from './offset.vue';
</script>
<style scoped>

<style lang="less" scoped>
.tdesign-mobile-demo {
background-color: #fff;
min-height: 100%;
box-sizing: border-box;
}
</style>
1 change: 1 addition & 0 deletions src/col/style/css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './index.css';
15 changes: 10 additions & 5 deletions src/row/row.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { computed, defineComponent, CSSProperties, provide } from 'vue';
import { convertUnit } from '../shared';
import RowProps from './props';
import props from './props';
import config from '../config';
import { rowInjectionKey } from './constants';
import { useTNodeJSX } from '../hooks/tnode';
import { usePrefixClass } from '../hooks/useClass';

const { prefix } = config;
const name = `${prefix}-row`;

export default defineComponent({
name,
props: RowProps,
setup(props, { slots }) {
props,
setup(props) {
const renderTNodeJSX = useTNodeJSX();
const componentName = usePrefixClass('row');

// row gutter style
const style = computed(() => {
const styles: CSSProperties = {};
Expand All @@ -30,8 +35,8 @@ export default defineComponent({

return () => {
return (
<div class={`${prefix}-row`} style={style.value}>
{slots.default?.()}
<div class={componentName.value} style={style.value}>
{renderTNodeJSX('default')}
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/row/style/css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './index.css';

0 comments on commit 960a87f

Please sign in to comment.