-
-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements our StyleGuide #7284
Conversation
This is nice 👏 Could you share a screenshot of storybook running? |
Storybook has a lot of dependencies, but yes,
NB: the component itself is not displaying because of the monkeypatch conflict I guess. |
Awesome! Well done 👏
…On Wed, 31 Mar 2021, 08:25 jibees, ***@***.***> wrote:
I wonder why so many changes in yarn.lock.
Storybook has a lot of dependencies, but yes, yarn.lock has large
modification. Maybe it has also update some of our pre-existing
dependencies?
Could you share a screenshot of storybook running?
Sure, very simple at this time:
[image: Capture d’écran 2021-03-31 à 09 21 17]
<https://user-images.githubusercontent.com/296452/113106255-d8cf8280-9202-11eb-924f-e81b64fc882e.png>
*NB*: the component itself is not displaying because of the monkeypatch
conflict I guess.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7284 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMQPOSVZJOPAQTANJG6DNDTGLE5NANCNFSM42CEAL2A>
.
|
Okay, option 1 is to use the ViewComponents config option Option 2 might get a bit messy, we'll have to add an additional monkey-patch to wicked_pdf ourselves. We might already have a problem there, in that the current version of wicked_pdf uses |
Thanks a lot @Matt-Yorkley: I've cherrypicked your two commits, and now the error disappeared. 💪 🙏 Now I'm facing over CORS errors:
|
It's possible those two commits might break PDF creation elsewhere in the app, it was a quick attempt at a potential fix, but it would need careful testing... |
I already tried to make print to pdf functionality to work on my machine, but i always failed... ;( |
Codecov Report
@@ Coverage Diff @@
## master #7284 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 631 633 +2
Lines 18090 18096 +6
=======================================
+ Hits 16846 16852 +6
Misses 1244 1244
Continue to review full report at Codecov.
|
Hot tip: -- .to receive(:render_to_string)
++ .to receive(:render_to_string_with_wicked_pdf) |
Thanks. I squashed your commit. 🙏 |
e696ce2
to
064bc70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I really appreciate how you take every challenge we through at you and learn along the way. You are making excellent progress.
I added some questions for my understanding. And do you think it would be possible to create a real example that we can use? Even if it's really small, like a text box somewhere.
1c01eb4
to
025ac73
Compare
Okay, -- render InvoiceRenderer.new.args(@order)
++ render_with_wicked_pdf InvoiceRenderer.new.args(@order) and this also indicates we have inadequate test coverage on that specific bit of PDF invoice printing, right? We can make a separate issue to cover it 👍 Are there any cases where we send PDFs attached to emails? The template for this email ☝️ basically just says "...please find attached invoice..." Edit: yep, it's in the same controller (line 81) but it goes via |
Thanks for feedback @Matt-Yorkley ! 👍
|
@sauloperez @Matt-Yorkley |
Thanks a lot for your tests, and for open issues. @filipefurtad0 I've added dependencies for this PR : blocked by #7456 and #7455 |
Yeah, I can take those two issues 👍
Me neither, but I think we recently merged a change to master that means we can now run those PDF tests locally. I haven't re-checked it yet though. As long as it passes manual testing here, I think we can cover those test coverage issues separately, without blocking this PR 👌 |
Yes, you're right, I agree. I remove dependencies. |
- Documentation : https://viewcomponent.org/ - Our template engine generator is haml
- With command: `rails generate component Example title --sidecar` - Delete generated spec file
- Add `ViewComponent::TestHelpers` to get the helper method `render_inline` - Use Capybara to expect some assertion
- Via `view_component_storybook` : https://github.com/jonspalmer/view_component_storybook - Configure both `view_component_storybook` and `storybook` - Add two addons: `@storybook/addon-docs` and `@storybook/addon-controls` Update config comment for clarity
- Thus, component can inherit from all CSS rules, rendering is as close as to the truth - Still need to import `admin` css file if we want to create components for admin part (and we probably want too). This will probably lead to overlapping problems between all CSS rules... - This is a bit hacky, but as our CSS files are packed by rails I didn't find any better solution. We could also use any sass loader, but with this solution we can be confident on the fact that the generated CSS is the one used by the server that finally displays the component
- Storybook need to access through a GET method on `/rails/stories/**` served by `ViewComponent::Storybook::StoriesController` - Configure exact policy with an initialized filter
- Once story has been created, still need to generate the story itself (in json file format). Help with command: `rake view_component_storybook:write_stories_json`
- Simple wrapper around `<h3 />` for distributor title, used in the shop front
and call WickedPdf::PdfHelper explicitly
@Matt-Yorkley |
Alright! After your changes, clicking "Print Invoice" on the Actions menu or visiting Can't think of anywhere else where pdfs are created, I think we're good to go now. Thanks for the quick fix 🚀 |
Alright, lets slap the button. Thanks @jibees, sorry it was such a convoluted journey! 😅 |
What? Why?
This PR is here to create a StyleGuide inside OFN using
view_component
andstorybook
How it works?
rails generate component Example title --sidecar
(see document for more details)spec/components/stories
folder and then transformed to be ready for Storybook with the command:rake view_component_storybook:write_stories_json
. This creates aexample_component.stories.json
, which is gitignored, but readable by StoryBook.yarn storybook
Source:
Release notes
Create our styleguide
Changelog Category: Technical changes
What should we test?
Issues I faced:
MonkeyPatch
For now, this is not functional. Indeed,
view_component
is using a monkeypatch to override#render
method since we're using Rails5.0 (seems to be ok with Rails5.2, but not sure): https://github.com/github/view_component/blob/main/lib/view_component/render_monkey_patch.rbAs
WickedPdf
used the same monkeypatch, seems to be a conflict, as noticed here: ViewComponent/view_component#288Not sure to totally understand, still need some investigation.
For the record, the error in the rails console:
Resolved by cherrypicked: 2b19ea9 and 3893c07