discourse/app/assets/stylesheets/common/base
chapoi 2ca06ba236
DEV: form-kit
This PR introduces FormKit, a component-based form library designed to simplify form creation and management. This library provides a single `Form` component, various field components, controls, validation mechanisms, and customization options. Additionally, it includes helpers to facilitate testing and writing specifications for forms.

1. **Form Component**:
   - The main component that encapsulates form logic and structure.
   - Yields various utilities like `Field`, `Submit`, `Alert`, etc.

   **Example Usage**:
   ```gjs
   import Form from "discourse/form";

   <template>
     <Form as |form|>
       <form.Field
         @name="username"
         @title="Username"
         @validation="required"
         as |field|
       >
         <field.Input />
       </form.Field>

       <form.Field @name="age" @title="Age" as |field|>
         <field.Input @type="number" />
       </form.Field>

       <form.Submit />
     </Form>
   </template>
   ```

2. **Validation**:
   - Built-in validation rules such as `required`, `number`, `length`, and `url`.
   - Custom validation callbacks for more complex validation logic.

   **Example Usage**:
   ```javascript
   validateUsername(name, value, data, { addError }) {
     if (data.bar / 2 === value) {
       addError(name, "That's not how maths work.");
     }
   }
   ```

   ```hbs
   <form.Field @name="username" @validate={{this.validateUsername}} />
   ```

3. **Customization**:
   - Plugin outlets for extending form functionality.
   - Styling capabilities through propagated attributes.
   - Custom controls with properties provided by `form` and `field`.

   **Example Usage**:
   ```hbs
   <Form class="my-form" as |form|>
     <form.Field class="my-field" as |field|>
       <MyCustomControl id={{field.id}} @onChange={{field.set}} />
     </form.Field>
   </Form>
   ```

4. **Helpers for Testing**:
   - Test assertions for form and field validation.

   **Example usage**:
   ```javascript
   assert.form().hasErrors("the form shows errors");
   assert.form().field("foo").hasValue("bar", "user has set the value");
   ```

   - Helper for interacting with he form

   **Example usage**:
   ```javascript
   await formKit().field("foo").fillIn("bar");
   ```

5. **Page Object for System Specs**:
   - Page objects for interacting with forms in system specs.
   - Methods for submitting forms, checking alerts, and interacting with fields.

   **Example Usage**:
   ```ruby
   form = PageObjects::Components::FormKit.new(".my-form")
   form.submit
   expect(form).to have_an_alert("message")
   ```

   **Field Interactions**:
   ```ruby
   field = form.field("foo")
   expect(field).to have_value("bar")
   field.fill_in("bar")
   ```


6. **Collections handling**:
   - A specific component to handle array of objects

   **Example Usage**:
   ```gjs
    <Form @data={{hash foo=(array (hash bar=1) (hash bar=2))}} as |form|>
      <form.Collection @name="foo" as |collection|>
        <collection.Field @name="bar" @title="Bar" as |field|>
          <field.Input />
        </collection.Field>
      </form.Collection>
    </Form>
   ```
2024-07-17 11:59:35 +02:00
..
_bookmark-list.scss FEATURE: Add bulk action to bookmark (#26856) 2024-05-22 12:50:21 -03:00
_index.scss DEV: Remove summarization code (#27373) 2024-07-02 08:51:47 -07:00
_topic-list.scss UX: Remove or replace button transitions with variable (#27527) 2024-06-20 19:51:20 +02:00
about.scss UX: fix spacing for about page headings (#25410) 2024-01-24 16:36:36 -05:00
activation.scss UX: hide sidebar toggle on account created route (#26299) 2024-03-21 15:29:07 -04:00
alert.scss UX: revert icon colour change in alerts (#24916) 2023-12-15 13:32:35 +01:00
bbcode.scss
category-list.scss FIX: Use same names for category CSS variables (#24527) 2023-11-24 16:42:24 +02:00
code_highlighting.scss UX: highlight code in em and strong blocks (#26435) 2024-03-29 16:41:12 -04:00
colorpicker.scss FEATURE: Use native color-picker (#15748) 2022-02-01 11:18:13 -03:00
compose.scss UX: Hide the error tooltip when focusing the topic title (#27531) 2024-06-19 11:55:29 -03:00
composer-user-selector.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
crawler_layout.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
d-icon.scss
d-image-grid.scss UX: always show image preview controls, improve spacing (#27489) 2024-06-17 08:43:43 -04:00
dialog.scss A11Y: disable non-essential CSS animations for reduced-motion users (#23571) 2023-09-14 17:31:43 -04:00
directory.scss DEV: update classes, remove unused CSS (#25825) 2024-02-23 09:14:37 -05:00
discourse.scss DEV: form-kit 2024-07-17 11:59:35 +02:00
edit-category.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
edit-topic-timer-modal.scss UX: minor fixes in topic action modal (#24772) 2023-12-07 14:54:56 +01:00
ember-select.scss
emoji.scss UX: improve emoji alignment for text (#19815) 2023-01-30 14:07:08 +01:00
empty-state.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
exception.scss DEV: Use css var font sizes (#18518) 2022-10-12 15:31:59 +02:00
explain-reviewable.scss DEV: Prettify negative numbers in reviewable score explanation (#23642) 2023-09-25 10:34:51 +01:00
faqs.scss FEATURE: remove category badge style options, set bullet style as default (#24198) 2023-11-13 10:46:15 -05:00
group.scss UX: improve group email setting wrap, cleanup styles (#25985) 2024-03-01 12:34:55 -05:00
groups.scss UX: Remove or replace button transitions with variable (#27527) 2024-06-20 19:51:20 +02:00
header.scss UX: fix featured link alignment, hide participants wrapper outside of PMs (#27636) 2024-06-27 13:47:12 -04:00
history.scss UX: add space between revision avatar and username (#27329) 2024-06-04 12:48:16 -04:00
json_schema.scss UX: Various improvements to JSON Schema editor (#24543) 2023-11-29 13:39:49 +03:00
lightbox.scss UX: vertical alignment for lighbox-wrapper (#27520) 2024-06-18 16:00:41 -04:00
login.scss UX: Streamline reset password page (#27341) 2024-06-05 15:22:59 +10:00
magnific-popup.scss A11Y: Better contrast for lightbox overlay links (#25208) 2024-01-10 14:07:49 -05:00
menu-panel.scss A11Y: improve notification panel layout for high zoom levels (#27848) 2024-07-10 15:50:34 -04:00
modal.scss UX: Remove or replace button transitions with variable (#27527) 2024-06-20 19:51:20 +02:00
new-user.scss UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
not-found.scss A11Y: improve markup of 404 page search form (#26322) 2024-03-22 11:09:53 -04:00
onebox.scss UX: prevent twitter like/retweet counts from wrapping (#27333) 2024-06-04 16:55:50 -04:00
personal-message.scss UX: new default border radius (#26560) 2024-04-08 22:21:57 +02:00
popup-menu.scss FIX: Restore legacy popup menu SCSS (#26864) 2024-05-03 12:27:09 -04:00
redirection.scss DEV: Use more css vars (#18561) 2022-10-12 16:05:42 +02:00
reorder-categories.scss UX: minor categories reorder fixes (#27249) 2024-05-29 18:58:25 -04:00
reviewables.scss UX: fix review queue category and tag alignment, whitespace (#25166) 2024-01-08 12:55:39 -05:00
revise-and-reject-post-reviewable.scss FEATURE: Add Revise... option for queued post reviewable (#23454) 2023-10-13 11:28:31 +10:00
rtl.scss FEATURE: Serve RTL versions of admin and plugins CSS bundles for RTL locales (#21876) 2023-06-01 05:27:11 +03:00
search-menu.scss UX: improve search result consistency (#27289) 2024-06-04 15:34:21 +10:00
search.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
share_link.scss UX: refactor .d-modal to use BEM and improve styling (#23967) 2023-11-15 10:14:47 +00:00
shared-drafts.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
sidebar-custom-section.scss UX: normal cursor on custom sidebar link icon (#24427) 2023-11-20 09:13:08 +11:00
sidebar-footer.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
sidebar-more-section-links.scss DEV: Remove default button classes from sidebar buttons (#26893) 2024-05-07 09:20:30 -04:00
sidebar-section-link.scss DEV: Remove default button classes from sidebar buttons (#26893) 2024-05-07 09:20:30 -04:00
sidebar-section.scss UX: update appropriate btn-flat instances to btn-transparent (#25945) 2024-02-29 11:47:07 +01:00
sidebar.scss DEV: Untangle the admin sidebar from the sidebar code (#27640) 2024-07-05 13:11:15 -03:00
static-login.scss REFACTOR: move shadow vars to css custom props (#22094) 2023-06-13 16:38:31 -04:00
tagging.scss UX: prevent the tag bullet from shrinking (#27669) 2024-07-01 16:49:49 -04:00
tooltip.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
topic-admin-menu.scss FIX: Select posts menu styles (#26857) 2024-05-03 01:33:09 -03:00
topic-post.scss UX: fix overflowing quote bar (#27938) 2024-07-16 21:17:44 +02:00
topic.scss DEV: Refactor topic admin menu to use <DMenu> (#26678) 2024-04-29 12:44:38 -03:00
upload.scss UX: simplify styles for image uploader (#25970) 2024-02-29 14:39:00 -05:00
user-badges.scss A11Y: improve /badges structure for screen readers (#27698) 2024-07-03 17:16:21 -04:00
user-tips.scss UX: Improvements to user tips (#26480) 2024-04-03 11:43:56 -04:00
user.scss UX: fix name & username width on profile summary (#27925) 2024-07-15 12:49:06 -04:00