Skip to content

feat: 布局 prop 加 paddingHorizontal / paddingVertical - #10

Merged
HarlonWang merged 1 commit into
mainfrom
feat/padding-axes
Sep 18, 2026
Merged

HarlonWang merged 1 commit into
mainfrom
feat/padding-axes

Conversation

@HarlonWang

@HarlonWang HarlonWang commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

背景

TrendingAI 订阅页的「省 x%」角标是横 6 / 竖 2,四边同值的 padding 表达不了(docs/roadmap.md 第 6 项的实战反馈)。

改动

  • 布局 prop 加 paddingHorizontal / paddingVertical:轴向值覆盖该轴,缺的轴用 padding(React Native 式级联),三者合成同一个 Modifier.padding(start, top, end, bottom),仍在 §2 顺序表第 5 槽位
  • 单边 paddingTop 等留待需求出现,届时进同一槽位、同一级联;不引入数组形态的 padding(components.md §2 已记)

验证

pnpm build && pnpm test(41 / 4 / 23)、pnpm schema:check、pnpm typecheck;:compose:testAndroidHostTest(NodeTreeTest 加 paddingHorizontal 转换断言)、:compose:apiCheck

🤖 Generated with Claude Code

Sourcery 总结

支持按轴指定布局内边距,同时保留与现有 padding 属性的兼容性。

新功能:

  • 添加水平和垂直布局内边距属性,并在未指定时回退到现有的全边内边距值。

增强:

  • 记录内边距的级联规则,并按照既有的布局修饰符顺序保留内边距应用。

文档:

  • 更新组件和 DSL 文档,说明按轴指定的内边距以及单边内边距的延后处理。

测试:

  • 扩展节点树测试覆盖范围,以支持解析水平内边距。
Original summary in English

Summary by Sourcery

Support axis-specific layout padding while preserving compatibility with the existing padding property.

New Features:

  • Add horizontal and vertical layout padding properties with fallback to the existing all-sides padding value.

Enhancements:

  • Document the padding cascade and retain padding application in the established layout modifier order.

Documentation:

  • Update component and DSL documentation for axis-specific padding and deferment of single-edge padding.

Tests:

  • Extend node tree coverage for parsing horizontal padding.

TrendingAI 订阅页的省 x% 角标要横 6 竖 2,四边同值的 padding 表达不了。轴向值覆盖该轴、
缺的轴用 padding(React Native 式级联),三者合成同一个 Modifier.padding,槽位不变。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @HarlonWang, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e973fe4f-5057-404e-a5a5-ca3891b8ac03


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeseerbot codeseerbot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CodeSeer 审查

结论:批准

摘要

本次改动在 Compose 侧将 padding、paddingHorizontal 和 paddingVertical 合成为同一条 Modifier.padding,并在 Kotlin schema、CLI schema 和生成的 TypeScript 类型中同步暴露新 prop。轴向值优先、未指定轴回退到统一 padding 的逻辑与文档描述一致。给出的改动中未发现会影响现有行为的明确问题。

整个 PR 至 8d306c9 · gpt-5.6-terra

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown
审查者指南(小型 PR 中折叠显示)

审查者指南

新增 paddingHorizontal 和 paddingVertical 布局 prop,贯通 schema、CLI DSL、生成类型与 Compose modifier 实现;轴向值优先覆盖对应方向,缺失方向回退到 padding,并通过节点解析测试及文档同步支持该级联语义。

padding 级联解析流程图

flowchart LR
    P[padding] --> H{paddingHorizontal exists?}
    P --> V{paddingVertical exists?}
    H -->|yes| HVAL[horizontal value]
    H -->|no| HFALLBACK[use padding]
    V -->|yes| VVAL[vertical value]
    V -->|no| VFALLBACK[use padding]
    HVAL --> M["Modifier.padding(start, top, end, bottom)"]
    HFALLBACK --> M
    VVAL --> M
    VFALLBACK --> M
Loading

文件级变更

变更 详情 文件
扩展布局 padding 属性,并在 Compose 侧统一解析为四边内边距。
  • 新增 paddingHorizontal 和 paddingVertical schema/DSL 定义及生成组件类型。
  • 按 React Native 式级联解析:轴向属性覆盖 padding,缺失轴回退到 padding,再生成单一四边 Modifier.padding;未指定轴使用 0.dp。
  • 保持 padding 在 modifier 顺序第 5 槽位,并同步文档对优先级及后续单边属性规划的说明。
compose/src/commonMain/kotlin/wang/harlon/tinyui/PageHost.kt
compose/src/commonMain/kotlin/wang/harlon/tinyui/schema/ComponentSchema.kt
packages/cli/src/schema/dsl.ts
packages/core/src/generated/components.ts
docs/components.md
补充节点属性解析测试,覆盖新的轴向 padding 属性。
  • 在 NodeTreeTest 中验证 paddingHorizontal 的 dp 值能够写入并读取。
compose/src/commonTest/kotlin/wang/harlon/tinyui/node/NodeTreeTest.kt

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,以根据该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时(重新)生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这项功能会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这项功能尤其有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义使用体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

新增 paddingHorizontal 和 paddingVertical 布局 prop,贯通 schema、CLI DSL、生成类型与 Compose modifier 实现;轴向值优先覆盖对应方向,缺失方向回退到 padding,并通过节点解析测试及文档同步支持该级联语义。

Flow diagram for cascading padding resolution

flowchart LR
    P[padding] --> H{paddingHorizontal exists?}
    P --> V{paddingVertical exists?}
    H -->|yes| HVAL[horizontal value]
    H -->|no| HFALLBACK[use padding]
    V -->|yes| VVAL[vertical value]
    V -->|no| VFALLBACK[use padding]
    HVAL --> M["Modifier.padding(start, top, end, bottom)"]
    HFALLBACK --> M
    VVAL --> M
    VFALLBACK --> M
Loading

File-Level Changes

Change Details Files
扩展布局 padding 属性,并在 Compose 侧统一解析为四边内边距。
  • 新增 paddingHorizontal 和 paddingVertical schema/DSL 定义及生成组件类型。
  • 按 React Native 式级联解析:轴向属性覆盖 padding,缺失轴回退到 padding,再生成单一四边 Modifier.padding;未指定轴使用 0.dp。
  • 保持 padding 在 modifier 顺序第 5 槽位,并同步文档对优先级及后续单边属性规划的说明。
compose/src/commonMain/kotlin/wang/harlon/tinyui/PageHost.kt
compose/src/commonMain/kotlin/wang/harlon/tinyui/schema/ComponentSchema.kt
packages/cli/src/schema/dsl.ts
packages/core/src/generated/components.ts
docs/components.md
补充节点属性解析测试,覆盖新轴向 padding 属性。
  • 在 NodeTreeTest 中验证 paddingHorizontal 的 dp 值能够写入并读取。
compose/src/commonTest/kotlin/wang/harlon/tinyui/node/NodeTreeTest.kt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@HarlonWang
HarlonWang merged commit 6d943c9 into main Sep 18, 2026
4 checks passed
@HarlonWang
HarlonWang deleted the feat/padding-axes branch September 18, 2026 01:32
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.

1 participant