diff --git a/examples/doc-viewer/app/components/home-gallery.tsx b/examples/doc-viewer/app/components/home-gallery.tsx index 913a02ae..9713a0aa 100644 --- a/examples/doc-viewer/app/components/home-gallery.tsx +++ b/examples/doc-viewer/app/components/home-gallery.tsx @@ -20,8 +20,292 @@ const ctaLabel: Record = { en: { start: "Get started", widgets: "Browse widgets" }, }; +const copyByLocale = { + en: { + controls_button: "Button", + controls_secondary: "Secondary", + controls_outline: "Outline", + controls_name: "Name", + controls_message: "Message", + controls_badge: "Badge", + controls_alert_dialog: "Alert Dialog", + controls_alert_title: "Allow accessory to connect?", + controls_alert_desc: + "Do you want to allow the USB accessory to connect to this device and your data?", + controls_deny: "Don't allow", + controls_allow: "Allow", + controls_button_group: "Button Group", + controls_quick_actions: "Quick Actions", + controls_mute: "Mute Conversation", + controls_mark_read: "Mark as Read", + controls_block: "Block User", + controls_delete: "Delete Conversation", + attachments_title: "Attachments", + attachments_description: "Upload, review, and manage your files.", + attachments_ready: "Ready to upload", + attachments_uploading: "Uploading - 64%", + attachments_processing: "Processing document", + attachments_failed: "Upload failed. Try again.", + attachments_uploaded: "Uploaded - 1.8 MB", + savings_title: "Savings Targets", + savings_description: + "Active milestones for 2024 across your portfolio. Monitor how close you are to each savings goal.", + savings_retirement: "RETIREMENT", + savings_retirement_value: "$420,000", + savings_retirement_achieved: "65% achieved", + savings_retirement_amount: "$273,000", + savings_real_estate: "REAL ESTATE", + savings_real_estate_value: "$85,000", + savings_real_estate_achieved: "32% achieved", + savings_real_estate_amount: "$27,200", + savings_warning: "You have not met your targets for this year.", + claim_label: "Claimable Balance", + claim_balance: "$1,211.29", + claim_pending: "Pending Setup", + claim_net_label: "Net Royalties", + claim_net: "$1,248.75", + claim_fee_label: "Processing Fee", + claim_fee: "-$37.46", + claim_total_label: "Total Ready to Claim", + claim_total: "$1,211.29 USD", + claim_description: + "Once your bank is connected, balances over $10 are automatically eligible for monthly distribution on the 15th of each month.", + deployment_title: "Deployment Status", + deployment_live: "Live", + deployment_description: "Production rollout for the documentation site.", + deployment_environment: "production", + deployment_percent: "82%", + deployment_build: "Build & test", + deployment_build_desc: "Windows, Linux and macOS passed.", + deployment_duration1: "2m 14s", + deployment_database: "Database migration", + deployment_database_desc: "Schema changes applied successfully.", + deployment_duration2: "38s", + deployment_edge: "Edge rollout", + deployment_edge_desc: "Shifting traffic across regions.", + deployment_warning_title: "One region is warming up", + deployment_warning_desc: "Traffic is still being shifted in eu-west.", + deployment_view_logs: "View logs", + deployment_rollback: "Rollback release", + deployment_copy_hash: "Copy commit hash", + deployment_redeploy: "Redeploy", + milestone_title: "Set a new milestone", + milestone_description: + "Define your financial target and we'll help you pace your savings.", + milestone_goal: "Goal Name", + milestone_goal_placeholder: "e.g. New Car", + milestone_target_amount: "Target Amount", + milestone_target_placeholder: "$15,000", + milestone_target_date: "Target Date", + milestone_date_placeholder: "Dec 2025", + milestone_create: "Create Goal", + milestone_cancel: "Cancel", + subscription_title: "Subscription & Billing", + subscription_description: + "Common questions about your account, plans, payments and cancellations.", + subscription_q1: "What subscription plans do you offer?", + subscription_a1: + "We offer three subscription tiers: Starter ($9/month), Professional ($29/month), and Enterprise ($99/month). Each plan includes increasing storage limits, API access, priority support, and team collaboration features.", + subscription_q2: "How does billing work?", + subscription_a2: + "Billing occurs automatically at the start of each billing cycle. We accept all major credit cards, PayPal, and ACH transfers for enterprise customers.", + subscription_q3: "How do I cancel my subscription?", + subscription_a3: + "You can cancel your subscription anytime from your account settings. There are no cancellation fees or penalties.", + subscription_q4: "Can I change plans later?", + subscription_a4: + "Yes. Upgrades take effect immediately and downgrades apply at the end of the current billing period.", + payout_title: "Payout Threshold", + payout_description: + "Set the minimum balance required before a payout is triggered.", + payout_currency_label: "Preferred Currency", + payout_currency: "USD — United States Dollar", + payout_currency_value: "usd", + payout_usd: "USD — United States Dollar", + payout_cny: "CNY — Chinese Yuan", + payout_jpy: "JPY — Japanese Yen", + payout_eur: "EUR — Euro", + payout_min_label: "Minimum Payout Amount", + payout_amount: "$2500.00", + payout_min: "$50 (MIN)", + payout_max: "$10,000 (MAX)", + payout_notes: "Notes", + payout_note_placeholder: "Add a note for this payout", + payout_save: "Save Threshold", + account_title: "Account Access", + account_description: "Update your credentials or re-authenticate.", + account_email: "Email Address", + account_password: "Current Password", + account_forgot: "FORGOT?", + account_update: "Update Security", + account_danger: "Danger Zone", + account_danger_desc: "Archive account and remove…", + distribute_title: "Distribute Track", + distribute_description: + "Upload your first master to start reaching listeners on Spotify, Apple Music, and more.", + distribute_create: "Create Release", + notifications_title: "Notifications", + notifications_description: + "Choose which email and push alerts you want to receive.", + notifications_transaction: "Transaction alerts", + notifications_transaction_desc: "Deposits, withdrawals, and transfers.", + notifications_security: "Security alerts", + notifications_security_desc: "Login attempts and account changes.", + notifications_milestones: "Goal milestones", + notifications_milestones_desc: "Updates at 25%, 50%, 75%, and 100%.", + notifications_market: "Market updates", + notifications_market_desc: "Daily portfolio summary and price alerts.", + notifications_save: "Save Preferences", + shortcuts_breadcrumb: "/Home/Profile/Statements/Documents/Payments", + shortcuts_change_limit: "Change transfer limit", + shortcuts_change_limit_desc: + "Adjust how much you can send from your balance.", + shortcuts_scheduled: "Scheduled transfers", + shortcuts_scheduled_desc: "Set up a transfer to send at a later date.", + shortcuts_recurring: "Recurring card payments", + shortcuts_recurring_desc: "Manage your repeated card transactions.", + }, + "zh-CN": { + controls_button: "按钮", + controls_secondary: "次要", + controls_outline: "描边", + controls_name: "姓名", + controls_message: "消息", + controls_badge: "徽章", + controls_alert_dialog: "警告对话框", + controls_alert_title: "允许配件连接吗?", + controls_alert_desc: "是否允许 USB 配件连接此设备并访问你的数据?", + controls_deny: "不允许", + controls_allow: "允许", + controls_button_group: "按钮组", + controls_quick_actions: "快捷操作", + controls_mute: "静音会话", + controls_mark_read: "标为已读", + controls_block: "屏蔽用户", + controls_delete: "删除会话", + attachments_title: "附件", + attachments_description: "上传、查看并管理你的文件。", + attachments_ready: "等待上传", + attachments_uploading: "上传中 - 64%", + attachments_processing: "正在处理文档", + attachments_failed: "上传失败,请重试。", + attachments_uploaded: "已上传 - 1.8 MB", + savings_title: "储蓄目标", + savings_description: + "2024 年的活跃里程碑,覆盖你的整个投资组合。随时了解你离每个储蓄目标还有多远。", + savings_retirement: "退休", + savings_retirement_value: "¥420,000", + savings_retirement_achieved: "已完成 65%", + savings_retirement_amount: "¥273,000", + savings_real_estate: "房地产", + savings_real_estate_value: "¥85,000", + savings_real_estate_achieved: "已完成 32%", + savings_real_estate_amount: "¥27,200", + savings_warning: "你尚未达成本年度目标。", + claim_label: "可提取余额", + claim_balance: "¥1,211.29", + claim_pending: "待设置", + claim_net_label: "净版税", + claim_net: "¥1,248.75", + claim_fee_label: "处理费", + claim_fee: "-¥37.46", + claim_total_label: "可提取总额", + claim_total: "¥1,211.29", + claim_description: + "绑定银行账户后,余额超过 ¥10 将自动获得每月 15 日发放的资格。", + deployment_title: "部署状态", + deployment_live: "在线", + deployment_description: "文档站点的生产环境发布。", + deployment_environment: "生产环境", + deployment_percent: "82%", + deployment_build: "构建与测试", + deployment_build_desc: "Windows、Linux 和 macOS 均已通过。", + deployment_duration1: "2分14秒", + deployment_database: "数据库迁移", + deployment_database_desc: "架构变更已成功应用。", + deployment_duration2: "38秒", + deployment_edge: "边缘节点发布", + deployment_edge_desc: "正在跨区域切换流量。", + deployment_warning_title: "一个区域正在预热", + deployment_warning_desc: "eu-west 的流量仍在切换。", + deployment_view_logs: "查看日志", + deployment_rollback: "回滚版本", + deployment_copy_hash: "复制提交哈希", + deployment_redeploy: "重新部署", + milestone_title: "设置新里程碑", + milestone_description: "定义你的财务目标,我们会帮你规划储蓄节奏。", + milestone_goal: "目标名称", + milestone_goal_placeholder: "例如:新车", + milestone_target_amount: "目标金额", + milestone_target_placeholder: "¥15,000", + milestone_target_date: "目标日期", + milestone_date_placeholder: "2025年12月", + milestone_create: "创建目标", + milestone_cancel: "取消", + subscription_title: "订阅与账单", + subscription_description: "关于账户、套餐、付款和取消的常见问题。", + subscription_q1: "你们提供哪些订阅套餐?", + subscription_a1: + "我们提供三档订阅:Starter(¥9/月)、Professional(¥29/月)和 Enterprise(¥99/月)。每个套餐都包含更高的存储上限、API 访问、优先支持和团队协作功能。", + subscription_q2: "账单如何计算?", + subscription_a2: + "账单会在每个计费周期开始时自动扣款。我们支持所有主流信用卡、PayPal,以及企业客户的 ACH 转账。", + subscription_q3: "如何取消订阅?", + subscription_a3: "你可以随时在账户设置中取消订阅。没有取消费或违约金。", + subscription_q4: "之后可以更改套餐吗?", + subscription_a4: "可以。升级会立即生效,降级会在当前计费周期结束时生效。", + payout_title: "提现阈值", + payout_description: "设置触发提现所需的最低余额。", + payout_currency_label: "首选货币", + payout_currency: "CNY — 人民币", + payout_currency_value: "cny", + payout_usd: "USD — 美元", + payout_cny: "CNY — 人民币", + payout_jpy: "JPY — 日元", + payout_eur: "EUR — 欧元", + payout_min_label: "最低提现金额", + payout_amount: "¥2500.00", + payout_min: "¥50(最低)", + payout_max: "¥10,000(最高)", + payout_notes: "备注", + payout_note_placeholder: "为此提现添加备注", + payout_save: "保存阈值", + account_title: "账户访问", + account_description: "更新你的凭据或重新进行身份验证。", + account_email: "邮箱地址", + account_password: "当前密码", + account_forgot: "忘记密码?", + account_update: "更新安全设置", + account_danger: "危险区域", + account_danger_desc: "归档账户并移除…", + distribute_title: "分发曲目", + distribute_description: + "上传你的第一首母带,开始在 Spotify、Apple Music 等平台触达听众。", + distribute_create: "创建发行", + notifications_title: "通知", + notifications_description: "选择你希望接收的邮件和推送提醒。", + notifications_transaction: "交易提醒", + notifications_transaction_desc: "存款、提现和转账。", + notifications_security: "安全提醒", + notifications_security_desc: "登录尝试和账户变更。", + notifications_milestones: "目标里程碑", + notifications_milestones_desc: "在 25%、50%、75% 和 100% 时更新。", + notifications_market: "市场动态", + notifications_market_desc: "每日投资组合摘要和价格提醒。", + notifications_save: "保存偏好", + shortcuts_breadcrumb: "/首页/个人资料/对账单/文档/付款", + shortcuts_change_limit: "更改转账限额", + shortcuts_change_limit_desc: "调整你可以从余额中发送的金额。", + shortcuts_scheduled: "定时转账", + shortcuts_scheduled_desc: "设置稍后发送的转账。", + shortcuts_recurring: "周期卡支付", + shortcuts_recurring_desc: "管理你的重复卡交易。", + }, +} as const; + const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => { const cta = ctaLabel[locale]; + const copy = copyByLocale[locale]; return (
@@ -53,20 +337,20 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => {
@@ -75,12 +359,14 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => {
- Badge - Secondary + {copy.controls_badge} + + {copy.controls_secondary} +
@@ -93,32 +379,35 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => {
- + - Allow accessory to connect? + {copy.controls_alert_title} - Do you want to allow the USB accessory to - connect to this device and your data? + {copy.controls_alert_desc} - Don't allow + {copy.controls_deny} - Allow + {copy.controls_allow} - + @@ -495,10 +705,10 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => { - Rollback release + {copy.deployment_rollback} - Copy commit hash + {copy.deployment_copy_hash} @@ -508,210 +718,250 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => { className="home-deploy-redeploy" > - Redeploy + {copy.deployment_redeploy}
- - - - Set a new milestone - - Define your financial target and we'll help you pace - your savings. - - - - Goal Name - - -
- - Target Amount - - - - Target Date - - -
- - -
-
- - - -
- Payout Threshold - -
- - Set the minimum balance required before a payout is - triggered. - - - Preferred Currency - - - - - - - - USD — United States Dollar - - - CNY — Chinese Yuan - - - JPY — Japanese Yen - - - EUR — Euro - - - - - - - Minimum Payout Amount - $2500.00 -
-
-
-
- $50 (MIN) - $10,000 (MAX) -
- - - Notes - - - - - - - - - - Account Access - - Update your credentials or re-authenticate. - - - - Email Address - - - -
- Current Password - -
- -
- - - - - - - Danger Zone - - Archive account and remove… - - - - - - -
-
- - +
- Distribute Track + {copy.distribute_title} - Upload your first master to start reaching listeners - on Spotify, Apple Music, and more. + {copy.distribute_description}
- +
+ + + {copy.claim_label} + {copy.claim_balance} +
+ +
+ {copy.claim_pending} + +
+
+
+ + {copy.claim_net_label} + + + {copy.claim_net} + +
+
+ + {copy.claim_fee_label} + + + {copy.claim_fee} + +
+
+
+ + {copy.claim_total_label} + + + {copy.claim_total} + +
+
+ + {copy.claim_description} + + + + + + +
+ {copy.payout_title} + +
+ + {copy.payout_description} + + + {copy.payout_currency_label} + + + + + + + + {copy.payout_usd} + + + {copy.payout_cny} + + + {copy.payout_jpy} + + + {copy.payout_eur} + + + + + + + {copy.payout_min_label} + + {copy.payout_amount} + +
+
+
+
+ + {copy.payout_min} + + + {copy.payout_max} + +
+ + + {copy.payout_notes} + + + + + + + + + + {copy.subscription_title} + + {copy.subscription_description} + + + + + + {copy.subscription_q1} + + + {copy.subscription_a1} + + + + + {copy.subscription_q2} + + + {copy.subscription_a2} + + + + + {copy.subscription_q3} + + + {copy.subscription_a3} + + + + + {copy.subscription_q4} + + + {copy.subscription_a4} + + + + + + + + + + {copy.milestone_title} + + {copy.milestone_description} + + + + {copy.milestone_goal} + + +
+ + + {copy.milestone_target_amount} + + + + + {copy.milestone_target_date} + + +
+ + +
+
+ - Notifications + {copy.notifications_title} - Choose which email and push alerts you want to receive. + {copy.notifications_description}
- Transaction alerts + {copy.notifications_transaction} - Deposits, withdrawals, and transfers. + {copy.notifications_transaction_desc}
@@ -719,10 +969,10 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => {
- Security alerts + {copy.notifications_security} - Login attempts and account changes. + {copy.notifications_security_desc}
@@ -730,39 +980,41 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => {
- Goal milestones + {copy.notifications_milestones} - Updates at 25%, 50%, 75%, and 100%. + {copy.notifications_milestones_desc}
- Market updates + + {copy.notifications_market} + - Daily portfolio summary and price alerts. + {copy.notifications_market_desc}
- + - Change transfer limit + {copy.shortcuts_change_limit} - Adjust how much you can send from your balance. + {copy.shortcuts_change_limit_desc} @@ -774,9 +1026,9 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => { - Scheduled transfers + {copy.shortcuts_scheduled} - Set up a transfer to send at a later date. + {copy.shortcuts_scheduled_desc} @@ -788,9 +1040,65 @@ const HomeGallery: FunctionWidget = ({ locale }: { locale: Locale }) => { - Recurring card payments + {copy.shortcuts_recurring} - Manage your repeated card transactions. + {copy.shortcuts_recurring_desc} + + + + + + + + + + + + {copy.account_title} + + {copy.account_description} + + + + {copy.account_email} + + + +
+ {copy.account_password} + +
+ +
+ + + + + + + {copy.account_danger} + + {copy.account_danger_desc} diff --git a/examples/doc-viewer/app/global.css b/examples/doc-viewer/app/global.css index a16aadcc..e78ba524 100644 --- a/examples/doc-viewer/app/global.css +++ b/examples/doc-viewer/app/global.css @@ -1096,7 +1096,6 @@ home-column { display: flex; flex-direction: column; gap: 10px; - min-height: 120px; padding: 14px; border-radius: 10px; background: #f7f7f7; @@ -1251,15 +1250,6 @@ home-column { margin-top: 4px; } -.home-account item, -.home-shortcuts item { - min-height: 76px; -} - -.home-card item { - align-items: flex-start; -} - .home-danger item-media { color: #e7000b; } diff --git a/examples/doc-viewer/xmake.lua b/examples/doc-viewer/xmake.lua index 53bfd695..ae25b2ff 100644 --- a/examples/doc-viewer/xmake.lua +++ b/examples/doc-viewer/xmake.lua @@ -6,6 +6,9 @@ target("doc-viewer") set_rundir("dist") add_deps("lcui") add_files("app/**.c") + if is_plat("windows") then + add_cxflags("/utf-8", {tools = "cl"}) + end add_installfiles("dist/(assets/*)") after_build(function (target) local src = path.join(os.projectdir(), "docs", "examples", "assets", "attachment") diff --git a/tests/integration/test_gallery_layout.c b/tests/integration/test_gallery_layout.c index a94bac06..1f00b63e 100644 --- a/tests/integration/test_gallery_layout.c +++ b/tests/integration/test_gallery_layout.c @@ -733,6 +733,66 @@ static void test_production_empty_icon(void) icon_center, box_center); } +static void test_home_item_actions_center(void) +{ + ui_widget_t *card = ui_create_card(); + ui_widget_t *body = ui_create_card_content(); + ui_widget_t *item = ui_create_item(); + ui_widget_t *media = ui_create_item_media(); + ui_widget_t *media_icon = ui_create_fluent_icon("settings"); + ui_widget_t *content = ui_create_item_content(); + ui_widget_t *title = ui_create_item_title(); + ui_widget_t *description = ui_create_item_description(); + ui_widget_t *actions = ui_create_item_actions(); + ui_widget_t *icon = ui_create_fluent_icon("chevron-right"); + float x = 0; + float y = 0; + float item_center; + float icon_center; + + ui_widget_add_class(card, "home-card"); + ui_widget_add_class(body, "home-card-body home-shortcuts"); + ui_widget_set_attr(media, "variant", "icon"); + ui_text_set_content(title, "Change transfer limit"); + ui_text_set_content(description, + "Adjust how much you can send from your balance."); + ui_widget_append(media, media_icon); + ui_widget_append(content, title); + ui_widget_append(content, description); + ui_widget_append(actions, icon); + ui_widget_append(item, media); + ui_widget_append(item, content); + ui_widget_append(item, actions); + ui_widget_append(body, item); + ui_widget_append(card, body); + ui_widget_append(ui_root(), card); + ui_load_css_string_global_chunks(); + ui_update(); + ui_update(); + + item_center = item->border_box.height * 0.5f; + ctest_equal_float("home item media icon should be 16px wide", + media_icon->border_box.width, 16.0f); + ctest_equal_float("home item media icon should be 16px high", + media_icon->border_box.height, 16.0f); + ctest_equal_float("home item media should align with the title line", + media->computed_style.padding_top, 1.5f); + ui_widget_get_offset(icon, item, &x, &y); + icon_center = y + icon->border_box.height * 0.5f; + + ctest_equal_int("home item should center its children", + item->computed_style.type_bits.align_items, + CSS_ALIGN_ITEMS_CENTER); + ctest_equal_int("home item actions should keep auto align-self", + actions->computed_style.type_bits.align_self, + CSS_ALIGN_SELF_AUTO); + ctest_equal_float("home item action icon should be vertically centered", + icon_center, item_center); + + ui_widget_destroy(card); + ui_clear_trash(); +} + static void test_gallery_empty_hover(void) { static const float widths[] = { 1600, 1500, 1400, 1300, 1280, @@ -884,6 +944,8 @@ void test_gallery_layout(void) ctest_describe("production description hover", test_production_description_hover); ctest_describe("production empty icon", test_production_empty_icon); + ctest_describe("production item actions", + test_home_item_actions_center); home_scene_destroy(); lcui_destroy();