@profoundry-us/loco_motion 0.0.5 → 0.0.7
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 +182 -83
- 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
|
|
@@ -42,9 +44,10 @@ your solution is aligned with our goals.
|
|
|
42
44
|
- [LocoMotion Components](#locomotion-components)
|
|
43
45
|
- [Install](#install)
|
|
44
46
|
- [Using Components](#using-components)
|
|
45
|
-
|
|
46
|
-
- [Tooling](#tooling)
|
|
47
|
-
- [Next Steps](#next-steps)
|
|
47
|
+
- [Developing](#developing)
|
|
48
|
+
- [Tooling](#tooling)
|
|
49
|
+
- [TODO / Next Steps](#todo--next-steps)
|
|
50
|
+
|
|
48
51
|
|
|
49
52
|
## About
|
|
50
53
|
|
|
@@ -458,16 +461,23 @@ recommned Rspec with [factory_bot](https://github.com/thoughtbot/factory_bot)
|
|
|
458
461
|
and [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers).
|
|
459
462
|
|
|
460
463
|
Finally, although both libraries offer some functionality for testing your user
|
|
461
|
-
interface, we recommend utilizing [
|
|
462
|
-
it more closely mimics the real user experience in a browser and it allows
|
|
463
|
-
to see in real-time what is happening, including in-browser debugging!
|
|
464
|
+
interface, we recommend utilizing [Playwright](https://playwright.dev/) instead
|
|
465
|
+
as it more closely mimics the real user experience in a browser and it allows
|
|
466
|
+
you to see in real-time what is happening, including in-browser debugging!
|
|
467
|
+
|
|
468
|
+
Although the common setup is to write your specs in JavaScript or TypeScript,
|
|
469
|
+
you can actually write your End to End tests in Ruby / Rspec by utilizing the
|
|
470
|
+
[playwright-ruby-client](https://playwright-ruby-client.vercel.app/)!
|
|
471
|
+
|
|
472
|
+
We'll have some guides and examples for this coming soon!
|
|
464
473
|
|
|
465
474
|
> [!NOTE]
|
|
466
|
-
>
|
|
467
|
-
>
|
|
468
|
-
>
|
|
469
|
-
>
|
|
470
|
-
>
|
|
475
|
+
> We used to recommend [Cypress](https://www.cypress.io) for End-to-End tests,
|
|
476
|
+
> but it's reliance on JavaScript and sometimes flakey tests caused us to search
|
|
477
|
+
> out a new solution / recommendation.
|
|
478
|
+
>
|
|
479
|
+
> We plan to have a writeup soon (an ADR specifically) on exactly why we made
|
|
480
|
+
> the switch.
|
|
471
481
|
|
|
472
482
|
## Authentication
|
|
473
483
|
|
|
@@ -668,9 +678,9 @@ a full set of UI components to help you build robust and full-featured apps.
|
|
|
668
678
|
|
|
669
679
|
> [!CAUTION]
|
|
670
680
|
> The LocoMotion components are being actively developed and are NOT ready for
|
|
671
|
-
> production / public use
|
|
672
|
-
>
|
|
673
|
-
>
|
|
681
|
+
> production / public use! We have finished basic versions of the DaisyUI
|
|
682
|
+
> Actions, DataDisplay, Navigation, and Feedback components, but we expect these
|
|
683
|
+
> to change (possibly quite a bit) as we begin to use them in projects.
|
|
674
684
|
|
|
675
685
|
### Install
|
|
676
686
|
|
|
@@ -679,25 +689,63 @@ Add the following to your `Gemfile` and re-run `bundle`:
|
|
|
679
689
|
```Gemfile
|
|
680
690
|
# Gemfile
|
|
681
691
|
|
|
682
|
-
gem "loco_motion", github: "profoundry-us/loco_motion", branch: "main"
|
|
692
|
+
gem "loco_motion", github: "profoundry-us/loco_motion", branch: "main", require: "loco_motion"
|
|
693
|
+
|
|
694
|
+
# or
|
|
695
|
+
|
|
696
|
+
gem "loco_motion-rails", "0.0.7", require: "loco_motion"
|
|
683
697
|
```
|
|
684
698
|
|
|
685
|
-
Next add the following
|
|
686
|
-
`tailwind.config.js`
|
|
687
|
-
you install):
|
|
699
|
+
Next add the following lines to the `contents` section of your
|
|
700
|
+
`tailwind.config.js` to import / build the proper files:
|
|
688
701
|
|
|
689
702
|
```js
|
|
690
|
-
|
|
691
|
-
`${process.env.GEM_HOME}/loco_motion-0.0.4/app/components/**/*.{rb,js,html.haml}`,
|
|
703
|
+
const { execSync } = require('child_process');
|
|
692
704
|
|
|
693
|
-
|
|
694
|
-
|
|
705
|
+
let locoBundlePath = execSync('bundle show loco_motion').toString().trim();
|
|
706
|
+
|
|
707
|
+
module.exports = {
|
|
708
|
+
content:[
|
|
709
|
+
`${locoBundlePath}/app/components/**/*.{rb,js,html.haml}`,
|
|
710
|
+
|
|
711
|
+
// ...
|
|
712
|
+
]
|
|
713
|
+
}
|
|
695
714
|
```
|
|
696
715
|
|
|
697
716
|
> [!WARNING]
|
|
698
717
|
> Note that this will not output anything if it fails to find the right
|
|
699
|
-
> directory, so your CSS may
|
|
700
|
-
>
|
|
718
|
+
> directory, so your CSS may not compile properly if this command fails or finds
|
|
719
|
+
> the wrong gem or an older gem.
|
|
720
|
+
|
|
721
|
+
Next, if you're using any of the components that require JavaScript (like the
|
|
722
|
+
Countdown component), you'll need to add the library as a dependency and include
|
|
723
|
+
those controllers in your `application.js` file.
|
|
724
|
+
|
|
725
|
+
```sh
|
|
726
|
+
npm add @profoundry-us/loco_motion
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
or
|
|
730
|
+
|
|
731
|
+
```sh
|
|
732
|
+
yarn add @profoundry-us/loco_motion
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
Then inside your `application.js` file, make sure to import and register the
|
|
736
|
+
relevant controllers.
|
|
737
|
+
|
|
738
|
+
```js
|
|
739
|
+
import { Application } from "@hotwired/stimulus"
|
|
740
|
+
|
|
741
|
+
import { CountdownController } from "@profoundry-us/loco_motion"
|
|
742
|
+
|
|
743
|
+
const application = Application.start()
|
|
744
|
+
|
|
745
|
+
application.register("countdown", CountdownController)
|
|
746
|
+
|
|
747
|
+
export { application }
|
|
748
|
+
```
|
|
701
749
|
|
|
702
750
|
### Using Components
|
|
703
751
|
|
|
@@ -707,64 +755,70 @@ the following code and refresh your page.
|
|
|
707
755
|
```haml
|
|
708
756
|
%body
|
|
709
757
|
.m-2.p-2.rounded.bg-red-400
|
|
710
|
-
=
|
|
711
|
-
|
|
712
|
-
.btn
|
|
713
|
-
= LocoMotion.hello_world
|
|
758
|
+
= session[:user_info].inspect
|
|
714
759
|
|
|
715
760
|
%div
|
|
716
|
-
= render(
|
|
761
|
+
= render(Daisy::Actions::ButtonComponent.new(title: "Click Me"))
|
|
717
762
|
|
|
718
763
|
%div
|
|
719
|
-
=
|
|
764
|
+
= daisy_button(css: "btn-primary") do
|
|
765
|
+
Click Me Too
|
|
720
766
|
|
|
721
|
-
|
|
722
|
-
= session[:user_info].inspect
|
|
767
|
+
= yield
|
|
723
768
|
```
|
|
724
769
|
|
|
725
|
-
You should see a
|
|
726
|
-
|
|
727
|
-
example Button and Fab components.
|
|
770
|
+
You should see a few buttons and the user info that we saved from OmniAuth
|
|
771
|
+
represented as a Ruby hash! Any other content you have will be rendered below.
|
|
728
772
|
|
|
729
|
-
|
|
773
|
+
## Developing
|
|
730
774
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
can't have a class inherit from two classes, we give you a way to override the
|
|
734
|
-
base class that all of our components inherit from.
|
|
775
|
+
To work on LocoMotion, first clone the repository and make sure you have Docker
|
|
776
|
+
installed and running on your machine.
|
|
735
777
|
|
|
736
|
-
|
|
737
|
-
|
|
778
|
+
Next, create a `.env.local` file with the following contents, making sure to
|
|
779
|
+
replace the Unsplash keys with real ones (you can create your own account or ask
|
|
780
|
+
Topher for his keys).
|
|
738
781
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
class ApplicationComponent < LocoMotion::BaseComponent
|
|
744
|
-
end
|
|
782
|
+
```.env
|
|
783
|
+
# .env.local
|
|
784
|
+
UNSPLASH_ACCESS_KEY="<< INSERT ACCESS KEY >>"
|
|
785
|
+
UNSPLASH_SECRET_KEY="<< INSERT SECRET KEY >>"
|
|
745
786
|
```
|
|
746
787
|
|
|
747
|
-
|
|
788
|
+
You should then be able to run `make rebuild` in the project directory and then
|
|
789
|
+
`make all-quick` to start the services.
|
|
748
790
|
|
|
791
|
+
> [!NOTE]
|
|
792
|
+
>
|
|
793
|
+
> We use `yarn link` in the `docs/demo/bin/setup` script to enable quick editing
|
|
794
|
+
> of the Javascript files so you don't have to publish new packages during
|
|
795
|
+
> testing.
|
|
796
|
+
>
|
|
797
|
+
> For the Ruby gem, we point directly to it via the `:path` option in the
|
|
798
|
+
> `Gemfile`. This means that we have a custom Heroku buildpack when we publish
|
|
799
|
+
> the demo site to move the files into the appropriate places.
|
|
800
|
+
>
|
|
801
|
+
> See https://github.com/profoundry-us/loco_motion-buildpack for more info.
|
|
749
802
|
|
|
750
|
-
|
|
751
|
-
|
|
803
|
+
From here, you can access the demo site at http://localhost:3000 and the YARD
|
|
804
|
+
docs at http://localhost:8808/docs/yard
|
|
752
805
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
Rails.application.config.after_initialize do
|
|
756
|
-
config.base_component_class = ApplicationComponent
|
|
757
|
-
end
|
|
806
|
+
You can type `make demo-shell` to open a shell inside the demo Docker container,
|
|
807
|
+
or `make loco-shell` to get a shell inside the gem's Docker container.
|
|
758
808
|
|
|
759
|
-
|
|
760
|
-
```
|
|
809
|
+
See the `Makefile` for all available commands.
|
|
761
810
|
|
|
762
|
-
> [!
|
|
763
|
-
>
|
|
764
|
-
>
|
|
765
|
-
> so
|
|
811
|
+
> [!WARNING]
|
|
812
|
+
>
|
|
813
|
+
> Right now, Rails doesn't auto-reload the LocoMotion library files when they
|
|
814
|
+
> change, so you might have to restart your server to get it to pickup the
|
|
815
|
+
> changes.
|
|
816
|
+
>
|
|
817
|
+
> ```sh
|
|
818
|
+
> make demo-restart
|
|
819
|
+
> ```
|
|
766
820
|
|
|
767
|
-
|
|
821
|
+
### Tooling
|
|
768
822
|
|
|
769
823
|
For VSCode, you may want to add the following to your settings to get
|
|
770
824
|
TailwindCSS Intellisense working properly.
|
|
@@ -786,24 +840,69 @@ TailwindCSS Intellisense working properly.
|
|
|
786
840
|
],
|
|
787
841
|
```
|
|
788
842
|
|
|
789
|
-
|
|
843
|
+
And because whitespace is important when developing inline components, you
|
|
844
|
+
should also add the following which prevents VSCode from adding a newline to the
|
|
845
|
+
bottom of your HAML files. This helps ensure that inline components don't have
|
|
846
|
+
trailing whitespace when using something like the `succeed` helper.
|
|
847
|
+
|
|
848
|
+
```json
|
|
849
|
+
"[haml]": {
|
|
850
|
+
"editor.formatOnSave": false
|
|
851
|
+
}
|
|
852
|
+
```
|
|
790
853
|
|
|
791
|
-
|
|
792
|
-
|
|
854
|
+
Alternatively, if your component is simple enough, moving the template inside
|
|
855
|
+
the `_component.rb` file's `call` method can also alleviate this problem.
|
|
793
856
|
|
|
794
|
-
|
|
795
|
-
- [x] Extract relevant pieces into a yard-loco_motion plugin
|
|
796
|
-
- [ ] Publish Gem and NPM packages with only the files those need
|
|
797
|
-
- [ ] Create a new YARD plugin to document `@part`s
|
|
798
|
-
- [ ] Extract alerts into a doc component (and / or the Daisy component)
|
|
857
|
+
So instead of
|
|
799
858
|
|
|
800
|
-
|
|
859
|
+
```haml
|
|
860
|
+
- # This file has a newline at the bottom which can cause problems
|
|
861
|
+
= part(:component) do
|
|
862
|
+
= content
|
|
801
863
|
|
|
802
|
-
|
|
864
|
+
```
|
|
803
865
|
|
|
804
|
-
|
|
805
|
-
more easily do development on the various parts without having to re-run `yarn`
|
|
806
|
-
every time.
|
|
866
|
+
you could do something like this:
|
|
807
867
|
|
|
808
|
-
|
|
809
|
-
|
|
868
|
+
```ruby
|
|
869
|
+
def call
|
|
870
|
+
part(:component) { content }
|
|
871
|
+
end
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
## TODO / Next Steps
|
|
875
|
+
|
|
876
|
+
There is a LOT left to be done. We're not currently seeking assistance, but if
|
|
877
|
+
you feel very strongly that you'd like to contribute, please reach out through
|
|
878
|
+
the GitHub Discussions feature and let us know!
|
|
879
|
+
|
|
880
|
+
- [x] Basic versions of DaisyUI Actions
|
|
881
|
+
- [x] Basic versions of DaisyUI Data Display
|
|
882
|
+
- [x] Basic versions of DaisyUI Navigation
|
|
883
|
+
- [x] Basic versions of DaisyUI Feedback
|
|
884
|
+
- [ ] Basic versions of DaisyUI Data Input
|
|
885
|
+
- [ ] Basic versions of DaisyUI Layout
|
|
886
|
+
- [ ] Basic versions of DaisyUI Mockup
|
|
887
|
+
- [ ] ~~Get YARD docs rendering with (better) Markdown~~ _**Working for now**_
|
|
888
|
+
- [x] Extract relevant pieces into a yard-loco_motion plugin
|
|
889
|
+
- [x] Publish Gem
|
|
890
|
+
- [x] Publish NPM package
|
|
891
|
+
- [x] Update YARD plugin to add `@part`s
|
|
892
|
+
- [x] Update YARD plugin to add `@loco_example`s with language support
|
|
893
|
+
- [x] Extract doc callouts into a doc component (and / or the Daisy component)
|
|
894
|
+
- [ ] Choose, recommend, and document a pagination gem
|
|
895
|
+
- [ ] Discuss caching techniques / setup
|
|
896
|
+
- [x] Create / publish a staging version of the demo site ([Demo Staging][2])
|
|
897
|
+
- [ ] Create / publish a staging version of the docs site
|
|
898
|
+
- [ ] Create / publish a production version of the demo site
|
|
899
|
+
- [ ] Create / publish a production version of the docs site
|
|
900
|
+
- [x] Update demo site to allow for a different docs site using ENV var
|
|
901
|
+
- [x] Update README to suggest Playwright
|
|
902
|
+
- [ ] Build some have docs / guides / examples for using playwright-ruby-client
|
|
903
|
+
- [x] See if we can build a `Tippable` concern that relevant components can
|
|
904
|
+
include to automatically add the tooltip param and classes where possible
|
|
905
|
+
|
|
906
|
+
[1]: https://loco-motion.profoundry.us/
|
|
907
|
+
[2]: https://loco-motion-demo-staging.profoundry.us/
|
|
908
|
+
[3]: https://loco-motion-demo-staging.profoundry.us/api-docs
|