@profoundry-us/loco_motion 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -67
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Crazy fast Rails development with modern tools and components leveraging
|
|
5
5
|
ViewComponent, TailwindCSS, DaisyUI and more!
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<img src="//loco-motion-docs.profoundry.us/images/loco-chats.png" width="500px" style="border: 1px solid #bbb; padding: 2px; border-radius: 10px;">
|
|
8
8
|
|
|
9
9
|
_**DISCLAIMER**_
|
|
10
10
|
|
|
@@ -13,10 +13,12 @@ In particular, new Daisy components are being added frequently and older
|
|
|
13
13
|
components are being updated with new features meaning the APIs are very likely
|
|
14
14
|
to change!
|
|
15
15
|
|
|
16
|
-
We
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
We expect to settle on and purchase a real domain name in the near future, but
|
|
17
|
+
for the time being, the latest documentation is available at the links below.
|
|
18
|
+
|
|
19
|
+
- [Docs / Demo (Latest Release)][1]
|
|
20
|
+
- [API Docs (Latest Release)][2]
|
|
21
|
+
- [Docs / Demo (Main Branch / Staging)][3]
|
|
20
22
|
|
|
21
23
|
Please reach out by opening an
|
|
22
24
|
[Issue](https://github.com/profoundry-us/loco_motion/issues) if you've found a
|
|
@@ -31,18 +33,19 @@ your solution is aligned with our goals.
|
|
|
31
33
|
- [About](#about)
|
|
32
34
|
- [Getting Started](#getting-started)
|
|
33
35
|
- [Installing / Setting up Rails](#installing--setting-up-rails)
|
|
36
|
+
- [Using UUIDs by Default](#using-uuids-by-default)
|
|
34
37
|
- [Install HAML (Optional)](#install-haml-optional)
|
|
35
38
|
- [Install DaisyUI (Optional)](#install-daisyui-optional)
|
|
36
39
|
- [Try Out Your Application](#try-out-your-application)
|
|
37
40
|
- [Debugging](#debugging)
|
|
38
41
|
- [Testing](#testing)
|
|
42
|
+
- [Services / Service Objects](#services--service-objects)
|
|
39
43
|
- [Authentication](#authentication)
|
|
40
44
|
- [Web Console](#web-console)
|
|
41
45
|
- [BetterErrors (Optional)](#bettererrors-optional)
|
|
42
46
|
- [LocoMotion Components](#locomotion-components)
|
|
43
47
|
- [Install](#install)
|
|
44
48
|
- [Using Components](#using-components)
|
|
45
|
-
- [Setting a Base Component Class](#setting-a-base-component-class)
|
|
46
49
|
- [Developing](#developing)
|
|
47
50
|
- [Tooling](#tooling)
|
|
48
51
|
- [TODO / Next Steps](#todo--next-steps)
|
|
@@ -202,6 +205,20 @@ Congratulations!
|
|
|
202
205
|
You can now visit [http://localhost:3000](http://localhost:3000) in your web
|
|
203
206
|
browser and see your running Rails application!
|
|
204
207
|
|
|
208
|
+
### Using UUIDs by Default
|
|
209
|
+
|
|
210
|
+
We believe strongly in migrating all of your primary keys to UUIDs to increase
|
|
211
|
+
security as well as avoiding potential scaling issues in the future.
|
|
212
|
+
|
|
213
|
+
To enable this by default, create the following file:
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
# config/initializers/generators.rb
|
|
217
|
+
Rails.application.config.generators do |generator|
|
|
218
|
+
generator.orm :active_record, primary_key_type: :uuid
|
|
219
|
+
end
|
|
220
|
+
```
|
|
221
|
+
|
|
205
222
|
### Install HAML (Optional)
|
|
206
223
|
|
|
207
224
|
While you can use the default ERB templating system that comes with Rails, we
|
|
@@ -460,16 +477,45 @@ recommned Rspec with [factory_bot](https://github.com/thoughtbot/factory_bot)
|
|
|
460
477
|
and [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers).
|
|
461
478
|
|
|
462
479
|
Finally, although both libraries offer some functionality for testing your user
|
|
463
|
-
interface, we recommend utilizing [
|
|
464
|
-
it more closely mimics the real user experience in a browser and it allows
|
|
465
|
-
to see in real-time what is happening, including in-browser debugging!
|
|
480
|
+
interface, we recommend utilizing [Playwright](https://playwright.dev/) instead
|
|
481
|
+
as it more closely mimics the real user experience in a browser and it allows
|
|
482
|
+
you to see in real-time what is happening, including in-browser debugging!
|
|
483
|
+
|
|
484
|
+
Although the common setup is to write your specs in JavaScript or TypeScript,
|
|
485
|
+
you can actually write your End to End tests in Ruby / Rspec by utilizing the
|
|
486
|
+
[playwright-ruby-client](https://playwright-ruby-client.vercel.app/)!
|
|
487
|
+
|
|
488
|
+
We'll have some guides and examples for this coming soon!
|
|
466
489
|
|
|
467
490
|
> [!NOTE]
|
|
468
|
-
>
|
|
469
|
-
>
|
|
470
|
-
>
|
|
471
|
-
>
|
|
472
|
-
>
|
|
491
|
+
> We used to recommend [Cypress](https://www.cypress.io) for End-to-End tests,
|
|
492
|
+
> but it's reliance on JavaScript and sometimes flakey tests caused us to search
|
|
493
|
+
> out a new solution / recommendation.
|
|
494
|
+
>
|
|
495
|
+
> We plan to have a writeup soon (an ADR specifically) on exactly why we made
|
|
496
|
+
> the switch.
|
|
497
|
+
|
|
498
|
+
## Services / Service Objects
|
|
499
|
+
|
|
500
|
+
It is best practice to separate your logic into Service Objects rather than
|
|
501
|
+
shoving all of it into your Controllers and Models.
|
|
502
|
+
|
|
503
|
+
One solution we really like is
|
|
504
|
+
[ActiveInteraction](https://github.com/AaronLasseigne/active_interaction).
|
|
505
|
+
|
|
506
|
+
It is very stable, has wonderful documentation, and gives you a clean way to
|
|
507
|
+
build your service objects with support for things like composed interactions
|
|
508
|
+
and even ActiveModel validations.
|
|
509
|
+
|
|
510
|
+
Add `gem 'active_interaction', '~> 5.3'` to your `Gemfile` and create a new
|
|
511
|
+
class called `ApplicationInteraction` if you want to give it a try!
|
|
512
|
+
|
|
513
|
+
```
|
|
514
|
+
# app/interactions/application_interaction.rb
|
|
515
|
+
class ApplicationInteraction < ActiveInteraction::Base
|
|
516
|
+
# Your interactions will inherit from this class!
|
|
517
|
+
end
|
|
518
|
+
```
|
|
473
519
|
|
|
474
520
|
## Authentication
|
|
475
521
|
|
|
@@ -670,9 +716,9 @@ a full set of UI components to help you build robust and full-featured apps.
|
|
|
670
716
|
|
|
671
717
|
> [!CAUTION]
|
|
672
718
|
> The LocoMotion components are being actively developed and are NOT ready for
|
|
673
|
-
> production / public use
|
|
674
|
-
>
|
|
675
|
-
>
|
|
719
|
+
> production / public use! We have finished basic versions of the DaisyUI
|
|
720
|
+
> Actions, DataDisplay, Navigation, and Feedback components, but we expect these
|
|
721
|
+
> to change (possibly quite a bit) as we begin to use them in projects.
|
|
676
722
|
|
|
677
723
|
### Install
|
|
678
724
|
|
|
@@ -681,7 +727,11 @@ Add the following to your `Gemfile` and re-run `bundle`:
|
|
|
681
727
|
```Gemfile
|
|
682
728
|
# Gemfile
|
|
683
729
|
|
|
684
|
-
gem "loco_motion", github: "profoundry-us/loco_motion", branch: "main"
|
|
730
|
+
gem "loco_motion", github: "profoundry-us/loco_motion", branch: "main", require: "loco_motion"
|
|
731
|
+
|
|
732
|
+
# or
|
|
733
|
+
|
|
734
|
+
gem "loco_motion-rails", "0.0.7", require: "loco_motion"
|
|
685
735
|
```
|
|
686
736
|
|
|
687
737
|
Next add the following lines to the `contents` section of your
|
|
@@ -703,8 +753,8 @@ Next add the following lines to the `contents` section of your
|
|
|
703
753
|
|
|
704
754
|
> [!WARNING]
|
|
705
755
|
> Note that this will not output anything if it fails to find the right
|
|
706
|
-
> directory, so your CSS may
|
|
707
|
-
>
|
|
756
|
+
> directory, so your CSS may not compile properly if this command fails or finds
|
|
757
|
+
> the wrong gem or an older gem.
|
|
708
758
|
|
|
709
759
|
Next, if you're using any of the components that require JavaScript (like the
|
|
710
760
|
Countdown component), you'll need to add the library as a dependency and include
|
|
@@ -758,57 +808,35 @@ the following code and refresh your page.
|
|
|
758
808
|
You should see a few buttons and the user info that we saved from OmniAuth
|
|
759
809
|
represented as a Ruby hash! Any other content you have will be rendered below.
|
|
760
810
|
|
|
761
|
-
### Setting a Base Component Class
|
|
762
|
-
|
|
763
|
-
Sometimes, you may want to override the way that LocoMotion handles things, or
|
|
764
|
-
provide some functionality yourself in a sub-class of our components. Since you
|
|
765
|
-
can't have a class inherit from two classes, we give you a way to override the
|
|
766
|
-
base class that all of our components inherit from.
|
|
767
|
-
|
|
768
|
-
This allows you to define a class that inherits from `LocoMotion::BaseComponent`
|
|
769
|
-
and then adds any special methods or overrides to our default components.
|
|
770
|
-
|
|
771
|
-
Create a file called `app/components/application_component.rb` with the following
|
|
772
|
-
contents:
|
|
773
|
-
|
|
774
|
-
```ruby
|
|
775
|
-
class ApplicationComponent < LocoMotion::BaseComponent
|
|
776
|
-
end
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
Then add the following to `config/initializers/loco_motion.rb`.
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
```ruby
|
|
783
|
-
LocoMotion.configure do |config|
|
|
784
|
-
|
|
785
|
-
# Override the base component class to inherit from our ApplicationComponent
|
|
786
|
-
# so that we can add our own overrides / methods.
|
|
787
|
-
Rails.application.config.after_initialize do
|
|
788
|
-
config.base_component_class = ApplicationComponent
|
|
789
|
-
end
|
|
790
|
-
|
|
791
|
-
end
|
|
792
|
-
```
|
|
793
|
-
|
|
794
|
-
> [!NOTE]
|
|
795
|
-
> It doesn't have to inherit from `ApplicationComponent`, you can use any class
|
|
796
|
-
> you want, so you could create a separate `CustomizedLocoMotionComponent` class
|
|
797
|
-
> so that you don't have any conflicts with your `ApplicationComponent`.
|
|
798
|
-
|
|
799
811
|
## Developing
|
|
800
812
|
|
|
801
813
|
To work on LocoMotion, first clone the repository and make sure you have Docker
|
|
802
814
|
installed and running on your machine.
|
|
803
815
|
|
|
816
|
+
Next, create a `.env.local` file with the following contents, making sure to
|
|
817
|
+
replace the Unsplash keys with real ones (you can create your own account or ask
|
|
818
|
+
Topher for his keys).
|
|
819
|
+
|
|
820
|
+
```.env
|
|
821
|
+
# .env.local
|
|
822
|
+
UNSPLASH_ACCESS_KEY="<< INSERT ACCESS KEY >>"
|
|
823
|
+
UNSPLASH_SECRET_KEY="<< INSERT SECRET KEY >>"
|
|
824
|
+
```
|
|
825
|
+
|
|
804
826
|
You should then be able to run `make rebuild` in the project directory and then
|
|
805
827
|
`make all-quick` to start the services.
|
|
806
828
|
|
|
807
829
|
> [!NOTE]
|
|
808
830
|
>
|
|
809
|
-
> We use `
|
|
810
|
-
>
|
|
811
|
-
>
|
|
831
|
+
> We use `yarn link` in the `docs/demo/bin/setup` script to enable quick editing
|
|
832
|
+
> of the Javascript files so you don't have to publish new packages during
|
|
833
|
+
> testing.
|
|
834
|
+
>
|
|
835
|
+
> For the Ruby gem, we point directly to it via the `:path` option in the
|
|
836
|
+
> `Gemfile`. This means that we have a custom Heroku buildpack when we publish
|
|
837
|
+
> the demo site to move the files into the appropriate places.
|
|
838
|
+
>
|
|
839
|
+
> See https://github.com/profoundry-us/loco_motion-buildpack for more info.
|
|
812
840
|
|
|
813
841
|
From here, you can access the demo site at http://localhost:3000 and the YARD
|
|
814
842
|
docs at http://localhost:8808/docs/yard
|
|
@@ -850,6 +878,37 @@ TailwindCSS Intellisense working properly.
|
|
|
850
878
|
],
|
|
851
879
|
```
|
|
852
880
|
|
|
881
|
+
And because whitespace is important when developing inline components, you
|
|
882
|
+
should also add the following which prevents VSCode from adding a newline to the
|
|
883
|
+
bottom of your HAML files. This helps ensure that inline components don't have
|
|
884
|
+
trailing whitespace when using something like the `succeed` helper.
|
|
885
|
+
|
|
886
|
+
```json
|
|
887
|
+
"[haml]": {
|
|
888
|
+
"editor.formatOnSave": false
|
|
889
|
+
}
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
Alternatively, if your component is simple enough, moving the template inside
|
|
893
|
+
the `_component.rb` file's `call` method can also alleviate this problem.
|
|
894
|
+
|
|
895
|
+
So instead of
|
|
896
|
+
|
|
897
|
+
```haml
|
|
898
|
+
- # This file has a newline at the bottom which can cause problems
|
|
899
|
+
= part(:component) do
|
|
900
|
+
= content
|
|
901
|
+
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
you could do something like this:
|
|
905
|
+
|
|
906
|
+
```ruby
|
|
907
|
+
def call
|
|
908
|
+
part(:component) { content }
|
|
909
|
+
end
|
|
910
|
+
```
|
|
911
|
+
|
|
853
912
|
## TODO / Next Steps
|
|
854
913
|
|
|
855
914
|
There is a LOT left to be done. We're not currently seeking assistance, but if
|
|
@@ -859,18 +918,35 @@ the GitHub Discussions feature and let us know!
|
|
|
859
918
|
- [x] Basic versions of DaisyUI Actions
|
|
860
919
|
- [x] Basic versions of DaisyUI Data Display
|
|
861
920
|
- [x] Basic versions of DaisyUI Navigation
|
|
862
|
-
- [
|
|
921
|
+
- [x] Basic versions of DaisyUI Feedback
|
|
863
922
|
- [ ] Basic versions of DaisyUI Data Input
|
|
864
923
|
- [ ] Basic versions of DaisyUI Layout
|
|
865
924
|
- [ ] Basic versions of DaisyUI Mockup
|
|
866
|
-
- [
|
|
925
|
+
- [x] ~~Get YARD docs rendering with (better) Markdown~~ _**Working for now**_
|
|
867
926
|
- [x] Extract relevant pieces into a yard-loco_motion plugin
|
|
868
|
-
- [
|
|
927
|
+
- [x] Publish Gem
|
|
869
928
|
- [x] Publish NPM package
|
|
870
|
-
- [
|
|
929
|
+
- [x] Update YARD plugin to add `@part`s
|
|
930
|
+
- [x] Update YARD plugin to add `@loco_example`s with language support
|
|
871
931
|
- [x] Extract doc callouts into a doc component (and / or the Daisy component)
|
|
872
|
-
- [ ] Choose
|
|
932
|
+
- [ ] Choose, recommend, and document a pagination gem
|
|
873
933
|
- [ ] Discuss caching techniques / setup
|
|
934
|
+
- [x] Create / publish a staging version of the demo site ([Demo Staging][2])
|
|
935
|
+
- [ ] Create / publish a staging version of the docs site
|
|
874
936
|
- [ ] Create / publish a production version of the demo site
|
|
875
937
|
- [ ] Create / publish a production version of the docs site
|
|
876
|
-
- [
|
|
938
|
+
- [x] Update demo site to allow for a different docs site using ENV var
|
|
939
|
+
- [x] Update README to suggest Playwright
|
|
940
|
+
- [ ] Build some have docs / guides / examples for using playwright-ruby-client
|
|
941
|
+
- [x] See if we can build a `Tippable` concern that relevant components can
|
|
942
|
+
include to automatically add the tooltip param and classes where possible
|
|
943
|
+
- [x] Rename `tail` methods to `end` since we use that in other places
|
|
944
|
+
- [x] Update CardComponent Figure to be a proper class like other components
|
|
945
|
+
- [x] Create a GitHub pull request template to standardize PR submissions
|
|
946
|
+
- [ ] See if we can update the Join component to auto-add the `join-item` CSS
|
|
947
|
+
under certain conditions
|
|
948
|
+
- [ ] Add title and description content_for blocks to all examples for SEO purposes
|
|
949
|
+
|
|
950
|
+
[1]: https://loco-motion.profoundry.us/
|
|
951
|
+
[2]: https://loco-motion-demo-staging.profoundry.us/
|
|
952
|
+
[3]: https://loco-motion-demo-staging.profoundry.us/api-docs
|