Branch protection rules are compact rows in one list, one open at a time, with a left-aligned two-column editor
Browse files at this commit881b74629c13edc34c9066ff81b0e9534cc680bcParent: 9d4e224- style
- branch protection rules are compact rows in one list, one open at a time, with a left-aligned two-column editor
4 changed files +179 -178
- crates/forge-web/src/i18n/repo_admin.rs +12 -0
- crates/forge-web/src/pages/repo_settings.rs +82 -68
- crates/forge-web/tests/e2e/repo_settings_e2e.rs +4 -4
- style/main.scss +81 -106
crates/forge-web/src/i18n/repo_admin.rsmodified+12 -0
| @@ -29,6 +29,7 @@ pub enum K { | |||
| 29 | BranchRuleRemoved, | 29 | BranchRuleRemoved, |
| 30 | BranchRuleSaved, | 30 | BranchRuleSaved, |
| 31 | BuiltinRowText, | 31 | BuiltinRowText, |
| 32 | + CancelRule, | ||
| 32 | CancelTransfer, | 33 | CancelTransfer, |
| 33 | ChangeVisibility, | 34 | ChangeVisibility, |
| 34 | CollabAdded, | 35 | CollabAdded, |
| @@ -50,6 +51,7 @@ pub enum K { | |||
| 50 | Description, | 51 | Description, |
| 51 | DescriptionHelp, | 52 | DescriptionHelp, |
| 52 | DescriptionLong, | 53 | DescriptionLong, |
| 54 | + EditRule, | ||
| 53 | EnterUsername, | 55 | EnterUsername, |
| 54 | EnterValue, | 56 | EnterValue, |
| 55 | ForcePushAllowed, | 57 | ForcePushAllowed, |
| @@ -79,6 +81,7 @@ pub enum K { | |||
| 79 | PrivateOption, | 81 | PrivateOption, |
| 80 | PublicOption, | 82 | PublicOption, |
| 81 | Remove, | 83 | Remove, |
| 84 | + RemoveRule, | ||
| 82 | RenameHelp, | 85 | RenameHelp, |
| 83 | RenameRepo, | 86 | RenameRepo, |
| 84 | RenameTransferNav, | 87 | RenameTransferNav, |
| @@ -219,6 +222,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 219 | (BuiltinRowText, Tr) => { | 222 | (BuiltinRowText, Tr) => { |
| 220 | " (varsayılan dal): varsayılan olarak korunur; bunu değiştirmek için bir kural ekleyin." | 223 | " (varsayılan dal): varsayılan olarak korunur; bunu değiştirmek için bir kural ekleyin." |
| 221 | } | 224 | } |
| 225 | + (CancelRule, En) => "Cancel", | ||
| 226 | + (CancelRule, Tr) => "Vazgeç", | ||
| 222 | (CancelTransfer, En) => "Cancel transfer", | 227 | (CancelTransfer, En) => "Cancel transfer", |
| 223 | (CancelTransfer, Tr) => "Devri iptal et", | 228 | (CancelTransfer, Tr) => "Devri iptal et", |
| 224 | (ChangeVisibility, En) => "Change visibility", | 229 | (ChangeVisibility, En) => "Change visibility", |
| @@ -281,6 +286,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 281 | (DescriptionLong, Tr) => { | 286 | (DescriptionLong, Tr) => { |
| 282 | "Açıklama en fazla 350 karakter olabilir. Hiçbir şey kaydedilmedi." | 287 | "Açıklama en fazla 350 karakter olabilir. Hiçbir şey kaydedilmedi." |
| 283 | } | 288 | } |
| 289 | + (EditRule, En) => "Edit", | ||
| 290 | + (EditRule, Tr) => "Düzenle", | ||
| 284 | (EnterUsername, En) => "Enter a username.", | 291 | (EnterUsername, En) => "Enter a username.", |
| 285 | (EnterUsername, Tr) => "Bir kullanıcı adı girin.", | 292 | (EnterUsername, Tr) => "Bir kullanıcı adı girin.", |
| 286 | (EnterValue, En) => "Enter a value.", | 293 | (EnterValue, En) => "Enter a value.", |
| @@ -355,6 +362,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 355 | (PublicOption, Tr) => "Herkese açık: herkes okuyabilir", | 362 | (PublicOption, Tr) => "Herkese açık: herkes okuyabilir", |
| 356 | (Remove, En) => "Remove", | 363 | (Remove, En) => "Remove", |
| 357 | (Remove, Tr) => "Kaldır", | 364 | (Remove, Tr) => "Kaldır", |
| 365 | + (RemoveRule, En) => "Remove rule", | ||
| 366 | + (RemoveRule, Tr) => "Kuralı kaldır", | ||
| 358 | (RenameHelp, En) => { | 367 | (RenameHelp, En) => { |
| 359 | "Letters, digits, '.', '_' and '-'. The old name keeps working: its web and clone URLs redirect to the new name." | 368 | "Letters, digits, '.', '_' and '-'. The old name keeps working: its web and clone URLs redirect to the new name." |
| 360 | } | 369 | } |
| @@ -674,6 +683,7 @@ mod tests { | |||
| 674 | K::BranchRuleRemoved, | 683 | K::BranchRuleRemoved, |
| 675 | K::BranchRuleSaved, | 684 | K::BranchRuleSaved, |
| 676 | K::BuiltinRowText, | 685 | K::BuiltinRowText, |
| 686 | + K::CancelRule, | ||
| 677 | K::CancelTransfer, | 687 | K::CancelTransfer, |
| 678 | K::ChangeVisibility, | 688 | K::ChangeVisibility, |
| 679 | K::CollabAdded, | 689 | K::CollabAdded, |
| @@ -695,6 +705,7 @@ mod tests { | |||
| 695 | K::Description, | 705 | K::Description, |
| 696 | K::DescriptionHelp, | 706 | K::DescriptionHelp, |
| 697 | K::DescriptionLong, | 707 | K::DescriptionLong, |
| 708 | + K::EditRule, | ||
| 698 | K::EnterUsername, | 709 | K::EnterUsername, |
| 699 | K::EnterValue, | 710 | K::EnterValue, |
| 700 | K::ForcePushAllowed, | 711 | K::ForcePushAllowed, |
| @@ -724,6 +735,7 @@ mod tests { | |||
| 724 | K::PrivateOption, | 735 | K::PrivateOption, |
| 725 | K::PublicOption, | 736 | K::PublicOption, |
| 726 | K::Remove, | 737 | K::Remove, |
| 738 | + K::RemoveRule, | ||
| 727 | K::RenameHelp, | 739 | K::RenameHelp, |
| 728 | K::RenameRepo, | 740 | K::RenameRepo, |
| 729 | K::RenameTransferNav, | 741 | K::RenameTransferNav, |
crates/forge-web/src/pages/repo_settings.rsmodified+82 -68
| @@ -525,9 +525,10 @@ async fn switch_row( | |||
| 525 | }) | 525 | }) |
| 526 | } | 526 | } |
| 527 | 527 | ||
| 528 | -/// The rule cards, then a muted row for the default branch when no rule covers it, then the New | 528 | +/// The rule list: one bordered box with a row per rule, then a muted row for the default branch |
| 529 | -/// rule card. A card opens with its rule's values. The card whose draft has an error opens with | 529 | +/// when no rule covers it, then the New rule row last. A rule row opens with its rule's values, |
| 530 | -/// the draft instead, and the New rule card opens with the draft when no card takes it. | 530 | +/// and the row whose draft has an error opens with the draft instead. The New rule row opens with |
| 531 | +/// the draft when no rule row takes it. The rows share one `name`, so opening one closes the rest. | ||
| 531 | #[component] | 532 | #[component] |
| 532 | async fn branch_rule_cards( | 533 | async fn branch_rule_cards( |
| 533 | lang: Lang, | 534 | lang: Lang, |
| @@ -544,52 +545,51 @@ async fn branch_rule_cards( | |||
| 544 | Ok(view! { | 545 | Ok(view! { |
| 545 | <div class="rule-list"> | 546 | <div class="rule-list"> |
| 546 | for card in cards.iter() { | 547 | for card in cards.iter() { |
| 547 | - <div class="rule-card"> | 548 | + <details class="rule-row" name="branch-rule" open=(card.open)> |
| 548 | - <div class="rule-card-head"> | 549 | + <summary> |
| 549 | - <details class="rule-details" open=(card.open)> | 550 | + <code class="rule-pattern">(card.draft.pattern.as_str())</code> |
| 550 | - <summary> | 551 | + <span class="rule-pills"> |
| 551 | - <span class="rule-summary-main"> | 552 | + for pill in card.pills.iter() { |
| 552 | - <code class="rule-pattern">(card.draft.pattern.as_str())</code> | 553 | + <span class=(pill.class)>(pill.text.as_str())</span> |
| 553 | - <span class="rule-pills"> | 554 | + } |
| 554 | - for pill in card.pills.iter() { | 555 | + </span> |
| 555 | - <span class=(pill.class)>(pill.text.as_str())</span> | 556 | + <span class="rule-end"> |
| 556 | - } | 557 | + <span class="rule-edit">(g::t(lang, K::EditRule))</span> |
| 557 | - </span> | 558 | + <span class="rule-chevron" aria-hidden="true"></span> |
| 558 | - </span> | 559 | + </span> |
| 559 | - <span class="rule-chevron" aria-hidden="true"></span> | 560 | + </summary> |
| 560 | - </summary> | 561 | + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), |
| 561 | - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), | 562 | + delete_action: delete_action.clone(), rule_id: Some(card.id.clone()), |
| 562 | - draft: card.draft.clone(), contexts: contexts.clone()) | 563 | + draft: card.draft.clone(), contexts: contexts.clone()) |
| 563 | - </details> | 564 | + </details> |
| 564 | - <form method="post" action=(delete_action.as_str()) class="remove-form"> | ||
| 565 | - <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 566 | - <input type="hidden" name="rule_id" value=(card.id.as_str())> | ||
| 567 | - <button type="submit">(g::t(lang, K::Remove))</button> | ||
| 568 | - </form> | ||
| 569 | - </div> | ||
| 570 | - </div> | ||
| 571 | } | 565 | } |
| 572 | if builtin_row { | 566 | if builtin_row { |
| 573 | - <div class="rule-card rule-builtin"> | 567 | + <div class="rule-builtin"> |
| 574 | <code class="rule-pattern">(default_branch.as_str())</code> | 568 | <code class="rule-pattern">(default_branch.as_str())</code> |
| 575 | <span class="muted small">(g::t(lang, K::BuiltinRowText))</span> | 569 | <span class="muted small">(g::t(lang, K::BuiltinRowText))</span> |
| 576 | </div> | 570 | </div> |
| 577 | } | 571 | } |
| 572 | + <details class="rule-row rule-new" name="branch-rule" open=(new_open)> | ||
| 573 | + <summary>"+ "(g::t(lang, K::NewRule))</summary> | ||
| 574 | + branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), | ||
| 575 | + delete_action: delete_action.clone(), rule_id: None, | ||
| 576 | + draft: new_draft, contexts: contexts.clone()) | ||
| 577 | + </details> | ||
| 578 | </div> | 578 | </div> |
| 579 | - <details class="rule-card rule-new" open=(new_open)> | ||
| 580 | - <summary>"+ "(g::t(lang, K::NewRule))</summary> | ||
| 581 | - branch_rule_form(lang: lang, csrf: csrf.clone(), save_action: save_action.clone(), | ||
| 582 | - draft: new_draft, contexts: contexts.clone()) | ||
| 583 | - </details> | ||
| 584 | }) | 579 | }) |
| 585 | } | 580 | } |
| 586 | 581 | ||
| 587 | -/// The rule form, in four sections. Saving an existing pattern updates its rule. | 582 | +/// The rule form: the pattern, the pushes and merging switches side by side on wide screens, and |
| 583 | +/// the checks. Saving an existing pattern updates its rule. An existing rule also gets a Remove | ||
| 584 | +/// button. Its delete form is a sibling of the rule form, because forms cannot nest, and the button | ||
| 585 | +/// submits it through its `form` attribute. | ||
| 588 | #[component] | 586 | #[component] |
| 589 | async fn branch_rule_form( | 587 | async fn branch_rule_form( |
| 590 | lang: Lang, | 588 | lang: Lang, |
| 591 | csrf: String, | 589 | csrf: String, |
| 592 | save_action: String, | 590 | save_action: String, |
| 591 | + delete_action: String, | ||
| 592 | + rule_id: Option<String>, | ||
| 593 | draft: RuleDraft, | 593 | draft: RuleDraft, |
| 594 | contexts: Vec<String>, | 594 | contexts: Vec<String>, |
| 595 | ) -> Result<impl View> { | 595 | ) -> Result<impl View> { |
| @@ -605,7 +605,15 @@ async fn branch_rule_form( | |||
| 605 | required_checks, | 605 | required_checks, |
| 606 | error, | 606 | error, |
| 607 | } = draft; | 607 | } = draft; |
| 608 | + // The delete form's id and the rule id it posts, for an existing rule only. | ||
| 609 | + let remove = rule_id.map(|id| (format!("remove-rule-{id}"), id)); | ||
| 608 | Ok(view! { | 610 | Ok(view! { |
| 611 | + if let Some((remove_id, id)) = &remove { | ||
| 612 | + <form method="post" action=(delete_action.as_str()) id=(remove_id.as_str())> | ||
| 613 | + <input type="hidden" name="csrf" value=(csrf.as_str())> | ||
| 614 | + <input type="hidden" name="rule_id" value=(id.as_str())> | ||
| 615 | + </form> | ||
| 616 | + } | ||
| 609 | <form method="post" action=(save_action.as_str()) class="rule-form"> | 617 | <form method="post" action=(save_action.as_str()) class="rule-form"> |
| 610 | if let Some(message) = error { | 618 | if let Some(message) = error { |
| 611 | alert(message: message.as_str()) | 619 | alert(message: message.as_str()) |
| @@ -619,39 +627,41 @@ async fn branch_rule_form( | |||
| 619 | </label> | 627 | </label> |
| 620 | <p class="muted small">(g::t(lang, K::PatternHelpA))<code>"*"</code>(g::t(lang, K::PatternHelpB))<code>"**"</code>(g::t(lang, K::PatternHelpC))<code>"/"</code>(g::t(lang, K::PatternHelpD))</p> | 628 | <p class="muted small">(g::t(lang, K::PatternHelpA))<code>"*"</code>(g::t(lang, K::PatternHelpB))<code>"**"</code>(g::t(lang, K::PatternHelpC))<code>"/"</code>(g::t(lang, K::PatternHelpD))</p> |
| 621 | </fieldset> | 629 | </fieldset> |
| 622 | - <fieldset class="rule-section"> | 630 | + <div class="rule-pair"> |
| 623 | - <legend>(g::t(lang, K::SectionPushes))</legend> | 631 | + <fieldset class="rule-section"> |
| 624 | - <div class="switch-list"> | 632 | + <legend>(g::t(lang, K::SectionPushes))</legend> |
| 625 | - switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push, | 633 | + <div class="switch-list"> |
| 626 | - title: g::t(lang, K::AllowForcePush).to_owned(), | 634 | + switch_row(name: "allow_force_push".to_owned(), checked: allow_force_push, |
| 627 | - description: Some(g::t(lang, K::ForcePushDesc).to_owned())) | 635 | + title: g::t(lang, K::AllowForcePush).to_owned(), |
| 628 | - switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion, | 636 | + description: Some(g::t(lang, K::ForcePushDesc).to_owned())) |
| 629 | - title: g::t(lang, K::AllowDeletion).to_owned(), | 637 | + switch_row(name: "allow_deletion".to_owned(), checked: allow_deletion, |
| 630 | - description: Some(g::t(lang, K::DeletionDesc).to_owned())) | 638 | + title: g::t(lang, K::AllowDeletion).to_owned(), |
| 631 | - switch_row(name: "restrict_push".to_owned(), checked: restrict_push, | 639 | + description: Some(g::t(lang, K::DeletionDesc).to_owned())) |
| 632 | - title: g::t(lang, K::RestrictPushTitle).to_owned(), | 640 | + switch_row(name: "restrict_push".to_owned(), checked: restrict_push, |
| 633 | - description: Some(g::t(lang, K::RestrictPushDesc).to_owned())) | 641 | + title: g::t(lang, K::RestrictPushTitle).to_owned(), |
| 634 | - </div> | 642 | + description: Some(g::t(lang, K::RestrictPushDesc).to_owned())) |
| 635 | - </fieldset> | 643 | + </div> |
| 636 | - <fieldset class="rule-section"> | 644 | + </fieldset> |
| 637 | - <legend>(g::t(lang, K::SectionMerging))</legend> | 645 | + <fieldset class="rule-section"> |
| 638 | - <div class="switch-list"> | 646 | + <legend>(g::t(lang, K::SectionMerging))</legend> |
| 639 | - <label class="switch-row"> | 647 | + <div class="switch-list"> |
| 640 | - <span class="switch-text"> | 648 | + <label class="switch-row"> |
| 641 | - <span class="switch-title">(g::t(lang, K::RequiredApprovals))</span> | 649 | + <span class="switch-text"> |
| 642 | - <span class="switch-desc">(g::t(lang, K::ApprovalsHelp))</span> | 650 | + <span class="switch-title">(g::t(lang, K::RequiredApprovals))</span> |
| 643 | - </span> | 651 | + <span class="switch-desc">(g::t(lang, K::ApprovalsHelp))</span> |
| 644 | - <input type="number" name="required_approvals" min="0" max="20" step="1" inputmode="numeric" value=(required_approvals.as_str())> | 652 | + </span> |
| 645 | - </label> | 653 | + <input type="number" name="required_approvals" min="0" max="20" step="1" inputmode="numeric" value=(required_approvals.as_str())> |
| 646 | - switch_row(name: "block_on_changes_requested".to_owned(), checked: block_on_changes_requested, | 654 | + </label> |
| 647 | - title: g::t(lang, K::BlockWhileChanges).to_owned(), description: None) | 655 | + switch_row(name: "block_on_changes_requested".to_owned(), checked: block_on_changes_requested, |
| 648 | - switch_row(name: "require_up_to_date".to_owned(), checked: require_up_to_date, | 656 | + title: g::t(lang, K::BlockWhileChanges).to_owned(), description: None) |
| 649 | - title: g::t(lang, K::RequireUpToDate).to_owned(), description: None) | 657 | + switch_row(name: "require_up_to_date".to_owned(), checked: require_up_to_date, |
| 650 | - switch_row(name: "require_merge_queue".to_owned(), checked: require_merge_queue, | 658 | + title: g::t(lang, K::RequireUpToDate).to_owned(), description: None) |
| 651 | - title: mq::t(lang, mq::K::RequireMergeQueue).to_owned(), | 659 | + switch_row(name: "require_merge_queue".to_owned(), checked: require_merge_queue, |
| 652 | - description: Some(mq::t(lang, mq::K::RequireMergeQueueHint).to_owned())) | 660 | + title: mq::t(lang, mq::K::RequireMergeQueue).to_owned(), |
| 653 | - </div> | 661 | + description: Some(mq::t(lang, mq::K::RequireMergeQueueHint).to_owned())) |
| 654 | - </fieldset> | 662 | + </div> |
| 663 | + </fieldset> | ||
| 664 | + </div> | ||
| 655 | <fieldset class="rule-section"> | 665 | <fieldset class="rule-section"> |
| 656 | <legend>(g::t(lang, K::SectionChecks))</legend> | 666 | <legend>(g::t(lang, K::SectionChecks))</legend> |
| 657 | <label> | 667 | <label> |
| @@ -669,7 +679,11 @@ async fn branch_rule_form( | |||
| 669 | } | 679 | } |
| 670 | </fieldset> | 680 | </fieldset> |
| 671 | <div class="form-actions"> | 681 | <div class="form-actions"> |
| 672 | - <button type="submit">(g::t(lang, K::SaveRule))</button> | 682 | + <button type="submit" class="primary">(g::t(lang, K::SaveRule))</button> |
| 683 | + <button type="button" data-close-details="">(g::t(lang, K::CancelRule))</button> | ||
| 684 | + if let Some((remove_id, _)) = &remove { | ||
| 685 | + <button type="submit" class="danger" form=(remove_id.as_str())>(g::t(lang, K::RemoveRule))</button> | ||
| 686 | + } | ||
| 673 | </div> | 687 | </div> |
| 674 | </form> | 688 | </form> |
| 675 | }) | 689 | }) |
crates/forge-web/tests/e2e/repo_settings_e2e.rsmodified+4 -4
| @@ -365,11 +365,11 @@ async fn repo_settings_deletes_rows_when_repo_dir_is_missing() { | |||
| 365 | ); | 365 | ); |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | -/// The rule cards of the branch rules list in page order, each as its pattern followed by the texts | 368 | +/// The rule rows of the branch rules list in page order, each as its pattern followed by the texts |
| 369 | -/// of its summary pills. The built-in default-branch card has no rule behind it, so it is skipped. | 369 | +/// of its summary pills. The built-in default-branch row has no rule behind it, so it is skipped. |
| 370 | fn branch_rows(body: &str) -> Vec<Vec<String>> { | 370 | fn branch_rows(body: &str) -> Vec<Vec<String>> { |
| 371 | let doc = scraper::Html::parse_document(body); | 371 | let doc = scraper::Html::parse_document(body); |
| 372 | - let cards = scraper::Selector::parse("div.rule-card:not(.rule-builtin)").expect("selector"); | 372 | + let cards = scraper::Selector::parse("details.rule-row:not(.rule-new)").expect("selector"); |
| 373 | let pattern = scraper::Selector::parse("summary code.rule-pattern").expect("selector"); | 373 | let pattern = scraper::Selector::parse("summary code.rule-pattern").expect("selector"); |
| 374 | let pills = scraper::Selector::parse("summary .rule-pill").expect("selector"); | 374 | let pills = scraper::Selector::parse("summary .rule-pill").expect("selector"); |
| 375 | let text = |el: scraper::ElementRef| el.text().collect::<String>().trim().to_owned(); | 375 | let text = |el: scraper::ElementRef| el.text().collect::<String>().trim().to_owned(); |
| @@ -383,7 +383,7 @@ fn branch_rows(body: &str) -> Vec<Vec<String>> { | |||
| 383 | .collect() | 383 | .collect() |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | -/// The card for `pattern` as its cells (see `branch_rows`), if the list has one. | 386 | +/// The row for `pattern` as its cells (see `branch_rows`), if the list has one. |
| 387 | fn rule_row(body: &str, pattern: &str) -> Option<Vec<String>> { | 387 | fn rule_row(body: &str, pattern: &str) -> Option<Vec<String>> { |
| 388 | branch_rows(body) | 388 | branch_rows(body) |
| 389 | .into_iter() | 389 | .into_iter() |
style/main.scssmodified+81 -106
| @@ -2764,46 +2764,34 @@ code { | |||
| 2764 | } | 2764 | } |
| 2765 | 2765 | ||
| 2766 | // branch protection | 2766 | // branch protection |
| 2767 | -// Settings page: one card per rule (a summary with its pills and the form when open), a muted row | 2767 | +// Settings page: one bordered list of rules. Each rule is a row: a one-line summary (pattern, pills, |
| 2768 | -// for the default branch when no rule covers it, and a dashed New rule card at the end. | 2768 | +// Edit and a chevron) that opens its form below it. The default-branch row, when no rule covers it, |
| 2769 | +// is a plain muted row, and New rule is the last row. | ||
| 2769 | .rule-list { | 2770 | .rule-list { |
| 2770 | display: flex; | 2771 | display: flex; |
| 2771 | flex-direction: column; | 2772 | flex-direction: column; |
| 2772 | - gap: 10px; | ||
| 2773 | margin-bottom: 10px; | 2773 | margin-bottom: 10px; |
| 2774 | -} | 2774 | + overflow: hidden; |
| 2775 | - | ||
| 2776 | -.rule-card { | ||
| 2777 | border: 1px solid var(--border); | 2775 | border: 1px solid var(--border); |
| 2778 | - border-radius: var(--radius-lg); | 2776 | + border-radius: var(--radius-md); |
| 2779 | background: var(--surface); | 2777 | background: var(--surface); |
| 2780 | -} | ||
| 2781 | - | ||
| 2782 | -// The rule card's bordered box holds the summary and the form, with Remove beside the summary row. | ||
| 2783 | -.rule-card-head { | ||
| 2784 | - display: flex; | ||
| 2785 | - align-items: flex-start; | ||
| 2786 | - | ||
| 2787 | - > .rule-details { | ||
| 2788 | - flex: 1 1 auto; | ||
| 2789 | - min-width: 0; | ||
| 2790 | - } | ||
| 2791 | 2778 | ||
| 2792 | - > .remove-form { | 2779 | + > * + * { |
| 2793 | - flex: none; | 2780 | + border-top: 1px solid var(--border); |
| 2794 | - margin: 10px 12px 0 0; | ||
| 2795 | } | 2781 | } |
| 2796 | } | 2782 | } |
| 2797 | 2783 | ||
| 2798 | -.rule-details { | 2784 | +// A rule row: the summary is one 44px line, and the form under it sits on the page background. |
| 2785 | +.rule-row { | ||
| 2799 | > summary { | 2786 | > summary { |
| 2800 | - display: flex; | 2787 | + display: grid; |
| 2788 | + grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; | ||
| 2801 | align-items: center; | 2789 | align-items: center; |
| 2802 | gap: 12px; | 2790 | gap: 12px; |
| 2803 | - padding: 12px 16px; | 2791 | + height: 44px; |
| 2792 | + padding: 0 14px; | ||
| 2804 | cursor: pointer; | 2793 | cursor: pointer; |
| 2805 | list-style: none; | 2794 | list-style: none; |
| 2806 | - border-radius: var(--radius-lg); | ||
| 2807 | 2795 | ||
| 2808 | &::-webkit-details-marker { | 2796 | &::-webkit-details-marker { |
| 2809 | display: none; | 2797 | display: none; |
| @@ -2814,16 +2802,24 @@ code { | |||
| 2814 | } | 2802 | } |
| 2815 | } | 2803 | } |
| 2816 | 2804 | ||
| 2817 | - &[open] > summary { | 2805 | + > .rule-form { |
| 2818 | - border-bottom: 1px solid var(--border); | 2806 | + border-top: 1px solid var(--border); |
| 2807 | + background: var(--bg); | ||
| 2808 | + } | ||
| 2809 | + | ||
| 2810 | + // The summary's Edit text and chevron. The chevron points down when closed and up when open. | ||
| 2811 | + > summary .rule-end { | ||
| 2812 | + display: flex; | ||
| 2813 | + align-items: center; | ||
| 2814 | + gap: 8px; | ||
| 2815 | + color: var(--muted); | ||
| 2816 | + font-size: 12px; | ||
| 2819 | } | 2817 | } |
| 2820 | 2818 | ||
| 2821 | - // The summary's chevron points down when closed and up when open. | ||
| 2822 | > summary .rule-chevron { | 2819 | > summary .rule-chevron { |
| 2823 | flex: none; | 2820 | flex: none; |
| 2824 | width: 7px; | 2821 | width: 7px; |
| 2825 | height: 7px; | 2822 | height: 7px; |
| 2826 | - margin: 0 4px 0 8px; | ||
| 2827 | border-right: 2px solid var(--muted); | 2823 | border-right: 2px solid var(--muted); |
| 2828 | border-bottom: 2px solid var(--muted); | 2824 | border-bottom: 2px solid var(--muted); |
| 2829 | transform: rotate(45deg); | 2825 | transform: rotate(45deg); |
| @@ -2835,33 +2831,32 @@ code { | |||
| 2835 | } | 2831 | } |
| 2836 | } | 2832 | } |
| 2837 | 2833 | ||
| 2838 | -.rule-summary-main { | ||
| 2839 | - display: flex; | ||
| 2840 | - flex: 1 1 auto; | ||
| 2841 | - flex-direction: column; | ||
| 2842 | - align-items: flex-start; | ||
| 2843 | - gap: 6px; | ||
| 2844 | - min-width: 0; | ||
| 2845 | -} | ||
| 2846 | - | ||
| 2847 | .rule-pattern { | 2834 | .rule-pattern { |
| 2835 | + min-width: 0; | ||
| 2848 | padding: 0; | 2836 | padding: 0; |
| 2849 | background: none; | 2837 | background: none; |
| 2850 | font-family: var(--mono); | 2838 | font-family: var(--mono); |
| 2851 | font-size: 15px; | 2839 | font-size: 15px; |
| 2852 | font-weight: 600; | 2840 | font-weight: 600; |
| 2853 | color: var(--text); | 2841 | color: var(--text); |
| 2854 | - overflow-wrap: anywhere; | 2842 | + white-space: nowrap; |
| 2843 | + overflow: hidden; | ||
| 2844 | + text-overflow: ellipsis; | ||
| 2855 | } | 2845 | } |
| 2856 | 2846 | ||
| 2847 | +// The pills share the middle column. When they run out of room, the last ones are cut off. | ||
| 2857 | .rule-pills { | 2848 | .rule-pills { |
| 2858 | display: flex; | 2849 | display: flex; |
| 2859 | - flex-wrap: wrap; | 2850 | + flex-wrap: nowrap; |
| 2860 | gap: 6px; | 2851 | gap: 6px; |
| 2852 | + min-width: 0; | ||
| 2853 | + overflow: hidden; | ||
| 2854 | + text-overflow: ellipsis; | ||
| 2861 | } | 2855 | } |
| 2862 | 2856 | ||
| 2863 | .rule-pill { | 2857 | .rule-pill { |
| 2864 | display: inline-flex; | 2858 | display: inline-flex; |
| 2859 | + flex: none; | ||
| 2865 | align-items: center; | 2860 | align-items: center; |
| 2866 | padding: 1px 8px; | 2861 | padding: 1px 8px; |
| 2867 | border: 1px solid var(--border); | 2862 | border: 1px solid var(--border); |
| @@ -2889,16 +2884,14 @@ code { | |||
| 2889 | } | 2884 | } |
| 2890 | } | 2885 | } |
| 2891 | 2886 | ||
| 2892 | -// The built-in default-branch row: muted, dashed, not a card to open. | 2887 | +// The built-in default-branch row: muted, one line, not clickable. |
| 2893 | .rule-builtin { | 2888 | .rule-builtin { |
| 2894 | - display: flex; | 2889 | + display: grid; |
| 2895 | - flex-direction: column; | 2890 | + grid-template-columns: minmax(0, auto) minmax(0, 1fr); |
| 2896 | - align-items: flex-start; | 2891 | + align-items: center; |
| 2897 | - gap: 6px; | 2892 | + gap: 12px; |
| 2898 | - padding: 12px 16px; | 2893 | + height: 44px; |
| 2899 | - border-style: dashed; | 2894 | + padding: 0 14px; |
| 2900 | - border-color: var(--border-strong); | ||
| 2901 | - background: none; | ||
| 2902 | color: var(--muted); | 2895 | color: var(--muted); |
| 2903 | 2896 | ||
| 2904 | .rule-pattern { | 2897 | .rule-pattern { |
| @@ -2906,47 +2899,22 @@ code { | |||
| 2906 | } | 2899 | } |
| 2907 | } | 2900 | } |
| 2908 | 2901 | ||
| 2909 | -// New rule: a dashed row that becomes a card once open. | 2902 | +// New rule: the last row, its one line in the accent colour. |
| 2910 | .rule-new { | 2903 | .rule-new { |
| 2911 | - border: 0; | ||
| 2912 | - background: none; | ||
| 2913 | - | ||
| 2914 | > summary { | 2904 | > summary { |
| 2915 | - display: block; | 2905 | + display: flex; |
| 2916 | - padding: 12px 16px; | 2906 | + align-items: center; |
| 2917 | - border: 1px dashed var(--border-strong); | 2907 | + height: 44px; |
| 2918 | - border-radius: var(--radius-lg); | 2908 | + padding: 0 14px; |
| 2919 | - color: var(--muted); | 2909 | + color: var(--accent-ink); |
| 2920 | font-weight: 600; | 2910 | font-weight: 600; |
| 2921 | - text-align: center; | ||
| 2922 | cursor: pointer; | 2911 | cursor: pointer; |
| 2923 | list-style: none; | 2912 | list-style: none; |
| 2924 | - | ||
| 2925 | - &::-webkit-details-marker { | ||
| 2926 | - display: none; | ||
| 2927 | - } | ||
| 2928 | - | ||
| 2929 | - &:hover { | ||
| 2930 | - border-color: var(--accent); | ||
| 2931 | - color: var(--accent); | ||
| 2932 | - } | ||
| 2933 | - } | ||
| 2934 | - | ||
| 2935 | - &[open] { | ||
| 2936 | - border: 1px solid var(--border); | ||
| 2937 | - border-radius: var(--radius-lg); | ||
| 2938 | - background: var(--surface); | ||
| 2939 | - } | ||
| 2940 | - | ||
| 2941 | - &[open] > summary { | ||
| 2942 | - border-style: none; | ||
| 2943 | - border-bottom: 1px solid var(--border); | ||
| 2944 | - border-radius: var(--radius-lg) var(--radius-lg) 0 0; | ||
| 2945 | - color: var(--text); | ||
| 2946 | } | 2913 | } |
| 2947 | } | 2914 | } |
| 2948 | 2915 | ||
| 2949 | -// The rule form: four sections, each with a small uppercase legend. | 2916 | +// The rule form: four sections, each with a small uppercase legend. Pushes and Merging sit side by |
| 2917 | +// side on wide screens. | ||
| 2950 | .rule-form { | 2918 | .rule-form { |
| 2951 | display: flex; | 2919 | display: flex; |
| 2952 | flex-direction: column; | 2920 | flex-direction: column; |
| @@ -2958,8 +2926,29 @@ code { | |||
| 2958 | max-width: 28rem; | 2926 | max-width: 28rem; |
| 2959 | } | 2927 | } |
| 2960 | 2928 | ||
| 2929 | + input[name="pattern"] { | ||
| 2930 | + max-width: 320px; | ||
| 2931 | + } | ||
| 2932 | + | ||
| 2961 | .form-actions { | 2933 | .form-actions { |
| 2962 | - justify-content: flex-end; | 2934 | + align-items: center; |
| 2935 | + | ||
| 2936 | + > .danger { | ||
| 2937 | + margin-left: auto; | ||
| 2938 | + } | ||
| 2939 | + } | ||
| 2940 | +} | ||
| 2941 | + | ||
| 2942 | +.rule-pair { | ||
| 2943 | + display: grid; | ||
| 2944 | + grid-template-columns: minmax(0, 1fr); | ||
| 2945 | + gap: 20px; | ||
| 2946 | +} | ||
| 2947 | + | ||
| 2948 | +@media (min-width: 900px) { | ||
| 2949 | + .rule-pair { | ||
| 2950 | + grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
| 2951 | + gap: 24px; | ||
| 2963 | } | 2952 | } |
| 2964 | } | 2953 | } |
| 2965 | 2954 | ||
| @@ -3004,15 +2993,16 @@ code { | |||
| 3004 | border-radius: var(--radius-md); | 2993 | border-radius: var(--radius-md); |
| 3005 | } | 2994 | } |
| 3006 | 2995 | ||
| 3007 | -// A row is a label: text on the left, the toggle or a number input on the right. Rows are split by | 2996 | +// A row is a label: the text in the left column, the toggle or a number input in the right one. |
| 3008 | -// a 1px divider. | 2997 | +// Rows are split by a 1px divider. |
| 3009 | .switch-row { | 2998 | .switch-row { |
| 3010 | - display: flex; | 2999 | + display: grid; |
| 3000 | + grid-template-columns: minmax(0, 1fr) auto; | ||
| 3011 | align-items: center; | 3001 | align-items: center; |
| 3012 | - justify-content: space-between; | 3002 | + column-gap: 16px; |
| 3013 | - gap: 16px; | 3003 | + padding: 10px 0; |
| 3014 | - padding: 12px 0; | ||
| 3015 | border-top: 1px solid var(--border); | 3004 | border-top: 1px solid var(--border); |
| 3005 | + text-align: left; | ||
| 3016 | cursor: pointer; | 3006 | cursor: pointer; |
| 3017 | 3007 | ||
| 3018 | &:first-child { | 3008 | &:first-child { |
| @@ -3080,23 +3070,8 @@ code { | |||
| 3080 | } | 3070 | } |
| 3081 | 3071 | ||
| 3082 | input[type="number"] { | 3072 | input[type="number"] { |
| 3083 | - flex: none; | 3073 | + width: 64px; |
| 3084 | - width: 72px; | 3074 | + max-width: 64px; |
| 3085 | - max-width: 72px; | ||
| 3086 | - } | ||
| 3087 | -} | ||
| 3088 | - | ||
| 3089 | -@media (max-width: 600px) { | ||
| 3090 | - .rule-details > summary { | ||
| 3091 | - padding: 10px 12px; | ||
| 3092 | - } | ||
| 3093 | - | ||
| 3094 | - .rule-form { | ||
| 3095 | - padding: 12px; | ||
| 3096 | - } | ||
| 3097 | - | ||
| 3098 | - .rule-card-head > .remove-form { | ||
| 3099 | - margin-right: 8px; | ||
| 3100 | } | 3075 | } |
| 3101 | } | 3076 | } |
| 3102 | 3077 | ||