Commit Graph

45 Commits

Author SHA1 Message Date
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
Joffrey JAFFEUX
17c92b4b2a
UX: shows the bookmark menu improvements
This commit adds a new option `@modalForMobile` for `<DMenu />` which allows to display a `<DModal />` when expanding a menu on mobile.

This commit also adds a `@views` options to toasts which is an array accepting `['mobile',  'desktop']` and will control if the toast is show on desktop and/or mobile.

Finally this commit allows to hide the progressBar even if the toast is set to `@autoClose=true`. This is controlled through the `@showProgressBar` option.
2024-04-08 08:18:50 +02:00
Penar Musaraj
4071af1d09
DEV: Refactor font and category background importers (#12312) 2021-03-10 11:05:56 -05:00
Penar Musaraj
303f229e98
DEV: Use indexes when importing SCSS from a folder (#11591)
By default, SCSS does not support globbing. This removes our magic and uses index files to import all files in a folder.
2020-12-30 15:29:10 -05:00
Michael Brown
d9a02d1336
Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse""
This reverts commit 20780a1eee.

* SECURITY: re-adds accidentally reverted commit:
  03d26cd6: ensure embed_url contains valid http(s) uri
* when the merge commit e62a85cf was reverted, git chose the 2660c2e2 parent to land on
  instead of the 03d26cd6 parent (which contains security fixes)
2020-05-23 00:56:13 -04:00
Jeff Atwood
20780a1eee Revert "Merge branch 'master' of https://github.com/discourse/discourse"
This reverts commit e62a85cf6f, reversing
changes made to 2660c2e21d.
2020-05-22 20:25:56 -07:00
Kris
62ecb2885f glob @import desktop and mobile scss 2020-05-20 18:05:27 -04:00
Joffrey JAFFEUX
9bbaaea1e8
UX: better customize emoji layout on mobile (#9319) 2020-03-31 08:55:47 +02:00
Kris
9e9d57d7ee General admin style cleanup 2019-10-04 13:25:54 -04:00
Vinoth Kannan
5bd6b70d98
DEV: debundle plugin css assets and don't load if disabled (#7646) 2019-08-20 22:09:52 +05:30
Penar Musaraj
f060c9b3ff UI: improvements to footer nav for app and PWAs
Adds support for iPad and Chrome PWAs

Better scroll direction logic when reaching bottom of the page
2019-04-11 14:11:26 -04:00
Penar Musaraj
eae22548de
Footer navigation for iOS PWAs and DiscourseHub app (#7347) 2019-04-10 12:23:18 -04:00
Joffrey JAFFEUX
e986e96227
DEV: removes old dashboard (#7295) 2019-04-01 12:39:49 +02:00
Robin Ward
b58867b6e9 FEATURE: New 'Reviewable' model to make reviewable items generic
Includes support for flags, reviewable users and queued posts, with REST API
backwards compatibility.

Co-Authored-By: romanrizzi <romanalejandro@gmail.com>
Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
2019-03-28 12:45:10 -04:00
Kris
7d92fa3a5e Mobile SCSS cleanup and removing unused styles 2019-01-23 14:36:53 -05:00
Jeff Wong
71d8807fec
Full height swipe-able menus (#6566)
* Feature: Full height swipe enabled menus

support pan events on iphone
2018-12-11 09:15:20 -08:00
Joffrey JAFFEUX
01913b9dc0 FIX: improves themes/components UI on mobile 2018-09-17 10:05:18 +02:00
Bianca Nenciu
4436024563 UX: Show only the expand icon in lightboxes on mobile. 2018-08-22 19:21:42 +02:00
Joffrey JAFFEUX
37d4f27c44
FIX: quality/bugfix dashboard/reports pass (#6283) 2018-08-17 16:19:25 +02:00
Joffrey JAFFEUX
60f62f6f36
FIX: improves report-show mobile UI (#6229) 2018-08-01 19:54:27 -04:00
Joffrey JAFFEUX
d75d1f0b51
FIX: improves moderation tab on mobile (#6122) 2018-07-19 23:59:52 -04:00
Guo Xiang Tan
19a93b0e95 UX: Improve groups page on mobile. 2018-03-19 18:48:12 +08:00
Kris
f375731278 About page layout improvements 2018-02-28 15:03:12 -05:00
Kris
b731d5d9b5 Removing unneeded and duplicate styles 2018-02-23 21:43:05 -05:00
Joffrey JAFFEUX
3a290ee625
FEATURE: replaces category/tag dropdowns by select-kit 2018-01-24 11:48:20 +01:00
minusfive
cdcc5d6174 Extracted/DRYed user-stream-item component CSS from user.css into own files
- Renamed 'stream-item' component to 'user-stream-item'
- Replaced generic 'item' class with clearer 'user-stream-item' class
- Retained 'item' class for backward compatibility, marked as 'DEPRECATED'
- Extracted CSS pertaining 'user-stream-item' component to component CSS files
- Removed unnecessary duplication from 'user-stream-item' CSS
- Removed unnecessary nesting from 'user-stream-item' CSS
2017-08-25 08:38:27 -07:00
Sam
a3e8c3cd7b FEATURE: Native theme support
This feature introduces the concept of themes. Themes are an evolution
of site customizations.

Themes introduce two very big conceptual changes:

- A theme may include other "child themes", children can include grand
children and so on.

- A theme may specify a color scheme

The change does away with the idea of "enabled" color schemes.

It also adds a bunch of big niceties like

- You can source a theme from a git repo

- History for themes is much improved

- You can only have a single enabled theme. Themes can be selected by
    users, if you opt for it.

On a technical level this change comes with a whole bunch of goodies

- All CSS is now compiled using a custom pipeline that uses libsass
    see /lib/stylesheet

- There is a single pipeline for css compilation (in the past we used
    one for customizations and another one for the rest of the app

- The stylesheet pipeline is now divorced of sprockets, there is no
   reliance on sprockets for CSS bundling

- CSS is generated with source maps everywhere (including themes) this
    makes debugging much easier

- Our "live reloader" is smarter and avoid a flash of unstyled content
   we run a file watcher in "puma" in dev so you no longer need to run
   rake autospec to watch for CSS changes
2017-04-12 10:53:49 -04:00
Guo Xiang Tan
e0c28d6fd5 REFACTOR: Stop mixing users page and groups page CSS. 2016-12-05 14:27:47 +08:00
Guo Xiang Tan
263a43bcfd UX: Use a gradient instead of a border. 2016-11-09 09:56:36 +08:00
Guo Xiang Tan
904a36eea2 UX: Emoji Toolbar was too wide on mobile. 2015-10-03 17:08:13 +08:00
Sam
e13ed24122 FEATURE: on mobile take users to full page search
UX: improve styling on full page search page
FEATURE: allow search context in full page search
FEATURE: visited color link for full page search
FIX: broken search help on fulls page search page
FEATURE: allow preload store to return a null
FEATURE: "mobileAction" for the header buttons
2015-09-08 11:04:03 +10:00
Robin Ward
4a6f617f4d UX: Long category names pushed badges to a new line in the hamburger 2015-09-02 15:42:20 -04:00
Robin Ward
e1f9f6d02a UX: Improve user directory on mobile 2015-05-11 11:20:46 -04:00
Régis Hanol
65dd05cb41 UX: fix revision history modal on mobile 2014-10-13 23:26:49 +02:00
Sam
af71307363 Add 10px margin for buttons in mobile 2014-08-23 10:41:48 +10:00
Régis Hanol
4f60eb6c77 FIX: banner on mobile 2014-08-08 12:31:32 +02:00
Régis Hanol
ab3d664ce0 BUGFIX: share alert styling with mobile 2014-07-07 17:46:32 +02:00
Robin Ward
952426d358 FEATURE: Uploaded images to categories are shown when browsing 2014-06-30 14:14:00 -04:00
Neil Lalonde
eb7aab3e0b FIX: revert button on all colors in a new color scheme 2014-05-14 10:19:00 -04:00
Neil Lalonde
c4d3aa3d47 Theming: a UI to choose some base colors that are applied to all the site css. CSS compiled outside of asset pipeline. 2014-05-14 10:18:12 -04:00
Benjamin Kampmann
64918c35f5 Improved Plugins SCSS management
- Moves the import of plugins for both mobile and desktop from common after discourse loading, allowing plugins to overwrite
 - Make desktop-option behave like the mobile-option: SCSS/CSS marked with that option will only be loaded for desktop from now on and ignored in mobile
 - Add variables-keyword, allowing plugins to ship and overwrite variables before they get imported by discourse (great for theming)
2014-04-25 18:25:45 +02:00
Vikhyat Korrapati
33307a50b3 Get rid of plugins.css, inject it using DiscourseSassImporter. 2014-04-09 19:42:43 +05:30
Vikhyat Korrapati
ef99ab59a5 Allow importing Discourse styles in custom stylesheets to modify vars. 2014-04-01 23:04:50 +05:30
Régis Hanol
77a8a4083a Revert "Merge pull request #2125 from vikhyat/css-variables"
This reverts commit b537de3ca5, reversing
changes made to b925827e5b.
2014-04-01 16:24:29 +02:00
Vikhyat Korrapati
ddd1dfe896 Allow importing Discourse styles in custom stylesheets to modify vars. 2014-04-01 15:25:43 +05:30