-
Notifications
You must be signed in to change notification settings - Fork 23
Adds Vue Styleguide #481 #482
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
base: master
Are you sure you want to change the base?
Conversation
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.
This looks really great @chrabyrd. Just a couple of minor comments.
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.
This is awesome! I just noted a few places where it would be helpful to have a little explanation about why a given good practice should be followed. Otherwise, this looks looks great and it'll be a key help for the community!
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.
Thank you!!
I'll do my best to start following this :-)
Passing Data | ||
~~~~~~~~~~~~ | ||
|
||
- **Fetch Proximity**: |
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.
On the projects you and I are working on right now, we have the luxury of writing as-svelte-as-we-can endpoints to deliver just-what's-needed. But I think not everyone will have that luxury.
Should we (briefly) advise to not go too far in the other direction, e.g. have a dozen children all fetching an identical response?
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.
Hmm this is a tough one. We do expect to have dozens of children hitting endpoints with identical responses. Eg widget config fetching, section data fetching, etc.
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.
Given that design, it's probably a sign we need to make sure we're sending appropriate cache headers. I think downstream caches will assume GET's are safe to cache, and if we have a bunch of perms-filtering logic, we need to clarify that with the correct headers.
~~~~~~~~~~~~~~ | ||
|
||
- **`rem` for nearly everything** | ||
Use `rem` units for spacing, typography, gaps, borders, and other dimensional values. |
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.
I think there usability/accessibility reasons we wouldn't want horizontal space and borders to scale with the font size, as argued here.
Whatever we land on, would be nice to get it enforced with stylelint or similar pre-commit hook, happy 2 help with this one 👍
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.
I've read that same article and I think it makes some salient points about how "rem" everywhere might not make sense especially considering accessibility.
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.
Let's table this for the moment, and loop back around after everything else settles. There is definitely discussion to be had here.
|
||
- **Side-Effects & Async Handling**: | ||
- No side-effects in the `<script>` tag. Encapsulate API calls, formatting logic, and other side-effects in lifecycle hooks or composables. | ||
- Wrap all async operations in `try/catch`, and surface or display errors appropriately. |
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.
How about then/except
?
- Wrap all async operations in `try/catch`, and surface or display errors appropriately. | |
- Wrap all async operations in `try/catch` or `then/except`, and surface or display errors appropriately. |
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.
where are you seeing a working JS pattern that uses except
?
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.
I think Alexei meant catch()
, which means he thought you meant try/except
, which means he didn't catch (ha) that you were intending to refer to both try
and .then().catch()
-- I take his point we could reword slightly to avoid this potential confusion
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.
where are you seeing a working JS pattern that uses
except
?
Thanks @jacobtylerwalls , yeah, I did mean catch
(python confusion there...) I think what I was pointing out was that .then().catch()
can be used as an alternative way to provide error handling for async functions.
Maybe what that really means is that this rule should emphasize the requirement to always handle for errors rather than be prescriptive about how you do it.
9. **Lifecycle hooks**: | ||
e.g. `onMounted()`, `onBeforeUnmount()` | ||
10. **Methods / functions** |
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.
I would prefer that 9 and 10 are reversed. Lifecycle hooks trigger/use all of the above. Those things tend to be the thing I know is the last part in the script tag. Even though I "get" function hoisting, I still naturally think about functions as being declared above the things that call them.
This also aligns with most code examples I've seen in the Vue docs themselves.
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.
This is something I feel pretty strongly about. The reason for this ordering is to support the 'big picture' flow of components. If I'm attempting to understand a new component, knowing when it does things is more important important information than how. Also we already have components that have hundreds of lines of functions, which I don't want to scroll through to get to the hooks. And conversely, would you expect defineExpose
, defineEmits
, watch
-ers, and computed
s to be declared below functions as well? As they can also use declared functions.
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.
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.
Examples in the Vue docs have lifecycle hooks as the last items in the script tag, and we, ourselves, tend to do that as well when I review what we've done in the past. I was really expressing a preference. But then this is what this whole exercise is about.
All in all, this looks great @chrabyrd ! Thanks for putting in so much thought, care, and hard work into this! Even though I have a couple of nits, I'm so grateful that you put this out there 🙏 |
readthedocs-sphinx-ext==2.1.4 | ||
sphinxcontrib-httpdomain | ||
requests[security] | ||
vue-lexer==0.0.4 |
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.
note -- this add vue-lexer
as a requirement. It'll need to be installed
- **Why?** | ||
- **Explicit API**: Readers, tools, and developers see exactly which fields the component needs. | ||
- **Immutable flow**: Primitives can't be mutated in place, preserving one-way data flow. | ||
- **Efficient updates**: Changes to unused object properties won't force re-renders. |
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.
Thanks for adding, I'm digging this now 👍
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.
Agreed! This is super helpful!
4. **External Arches Vue components** | ||
5. **Local Vue components** | ||
6. **External Arches utilities/composables** |
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.
Seems to not follow 8-10 below which do 3rd party, 2nd party (arches apps), 1st party
@chrabyrd @jacobtylerwalls @apeters How are we feeling about this PR? Should we wait until you all catch your breath after the v8 release? I'm happy to look at it again, but I don't want to distract you all right now. |
@chrabyrd just checking in about this. How are things going with this update? Is there anything I can review, or otherwise help with? |
👋 @ekansa Good question! Just been busy of late. Lemme give this a once-over and get back to you 👍 |
brief description of changes
Adds Vue Style Guide, majorly changes Vue Integration Guide.
issues addressed
#481
This box must be checked
This box should be checked
This box should only be checked you intend to follow through on it (we can do it on our end too)
cherry-pick
all commits in this PR into other branches that should have them after this PR is merged