Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Apr 25, 2020

summary 新增一种数据格式,用于支持固定列的展示:

<Table
  {...props}
  summary={() => (
    <tr>
      <Table.SummaryCell index={0} colSpan={2}>
        Light
      </Table.SummaryCell>
      <Table.SummaryCell index={2}>Bamboo</Table.SummaryCell>
    </tr>
  )}
/>

preview: https://table-git-fixed.react-component.now.sh/iframe.html?id=rc-table--fixedcolumns


原:

<Table
  {...props}
  summary={() => [
    [
      { children: 'Light', props: { colSpan: 2 } },
      { children: 'Hidden', props: { colSpan: 0 } },
      { children: 'Bamboo' },
    ],
  ]}
/>

@zombieJ zombieJ requested a review from afc163 April 25, 2020 14:40
@vercel
Copy link

vercel bot commented Apr 25, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/table/l11zn5amj
✅ Preview: https://table-git-fixed.react-component.now.sh

@codecov
Copy link

codecov bot commented Apr 25, 2020

Codecov Report

Merging #463 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #463   +/-   ##
=======================================
  Coverage   99.69%   99.69%           
=======================================
  Files          21       23    +2     
  Lines         652      661    +9     
  Branches      185      186    +1     
=======================================
+ Hits          650      659    +9     
  Misses          2        2           
Impacted Files Coverage Δ
src/Body/index.tsx 100.00% <ø> (ø)
src/context/TableContext.tsx 100.00% <ø> (ø)
src/Body/BodyRow.tsx 100.00% <100.00%> (ø)
src/Footer/Cell.tsx 100.00% <100.00%> (ø)
src/Footer/Row.tsx 100.00% <100.00%> (ø)
src/Footer/index.tsx 100.00% <100.00%> (ø)
src/Table.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b91d49...5687cb6. Read the comment docs.

@afc163
Copy link
Member

afc163 commented Apr 25, 2020

还是上了纯数据格式?原来的 tr td 还推荐不?

@afc163
Copy link
Member

afc163 commented Apr 25, 2020

和固定列有啥关系?

@zombieJ
Copy link
Member Author

zombieJ commented Apr 25, 2020

数据形式用于数组的 index 对应到 columns 的 index。原本的 jsx 看起来更直观,是共存的。不过现在想想似乎还有其他更好的形式。我先 hold 住它。再搞搞。

@zombieJ zombieJ changed the title feat: Table summary support fixed column [WIP] feat: Table summary support fixed column Apr 25, 2020
@afc163
Copy link
Member

afc163 commented Apr 26, 2020

都上 Table.SummaryCell 了,不如把 Table.Row 也放上去。

@afc163
Copy link
Member

afc163 commented Apr 26, 2020

SummaryCell 和 Cell 会有什么功能上的区别么?

@zombieJ
Copy link
Member Author

zombieJ commented Apr 26, 2020

RowCell 是比较底层的组件,它有很多属性需要配置。一部分属性是 Table 计算出来的值,不适合直接给用户用。也没想过把这些组件完全暴露给用户,以防止用户搞不懂各个 prop 是干啥的,也防止用户用了一些特殊方法,影响未来重构的兼容问题。

SummaryCell 是基于 Cell 的封装,只提供有限能力:colSpan rowSpan className。都是比较通用的属性。

@afc163
Copy link
Member

afc163 commented Apr 26, 2020

index 感觉是可以算出来的?

@afc163
Copy link
Member

afc163 commented Apr 26, 2020

如果希望和内部的 Row/Cell 做区分,这样如何?

<Table.SummaryRow>
  <Table.SummaryCell rowSpan={2} />
  <Table.SummaryCell rowSpan={3} />
  <Table.SummaryCell />
</Table.SummaryRow>

比起 tr 和 SummaryCell 混用看起来舒服一些。

@zombieJ
Copy link
Member Author

zombieJ commented Apr 26, 2020

index 需要给出,以防止用户用 HOC 包一个:

const MyCell = () => <><SummaryCell /><SummaryCell /></>

SummaryRow 我觉得 OK 的。这样还能额外添加 className 做样式处理。那就:
Table.Summary.RowTable.Summary.Cell

@zombieJ
Copy link
Member Author

zombieJ commented Apr 26, 2020

done.

@zombieJ zombieJ changed the title [WIP] feat: Table summary support fixed column feat: Table summary support fixed column Apr 26, 2020
@zombieJ zombieJ merged commit d37eb35 into master Apr 26, 2020
@delete-merged-branch delete-merged-branch bot deleted the fixed branch April 26, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants