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
activation.scss UX: hide sidebar toggle on account created route (#26299) 2024-03-21 15:29:07 -04:00
alert.scss
bbcode.scss
category-list.scss
code_highlighting.scss UX: highlight code in em and strong blocks (#26435) 2024-03-29 16:41:12 -04:00
colorpicker.scss
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
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
directory.scss
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
ember-select.scss
emoji.scss
empty-state.scss
exception.scss
explain-reviewable.scss
faqs.scss
group.scss
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
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
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
reorder-categories.scss UX: minor categories reorder fixes (#27249) 2024-05-29 18:58:25 -04:00
reviewables.scss
revise-and-reject-post-reviewable.scss
rtl.scss
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
shared-drafts.scss DEV: unused CSS cleanup, variable updates, simplification (#26111) 2024-03-11 09:07:53 -04:00
sidebar-custom-section.scss
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
sidebar.scss DEV: Untangle the admin sidebar from the sidebar code (#27640) 2024-07-05 13:11:15 -03:00
static-login.scss
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
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