toPlatformCase component helper
See original GitHub issuetoPlatformCase
In #5744 we added toPlatformCase
, a helper function to change this pattern:
to this:
The idea is that toPlatformCase
will case the string properly depending on the current platform. macOS is title case and windows is sentence case generally.
The original pattern appears in about 85 places in Desktop’s React components, according to a quick search of the codebase. (Currently toPlatformCase
is only used in one component.)
Limitations
There are limitations to this approach because there are a number of edge cases that extend beyond simply title casing or sentence casing a string.
- Prepositions (https://github.com/desktop/desktop/pull/5841#pullrequestreview-162478757), which are lower case, even in title case.
- Platform-specific terminology (#2103), like trash or recycling bin
- Key shortcuts (#2103), which differ on platforms
The Question
Options:
- keep
toPlatformCase
and spread in the codebase (where applicable) - remove
toPlatformCase
and continue using string literals in our components - refactor
toPlatformCase
to cover more edge cases - something else?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Sharing JavaScript Code in a Component Bundle
A helper function can be called from any JavaScript code in a component's bundle, such as from a client-side controller or renderer. Helper...
Read more >{{component helper}} - DockYard
A helpful helper that became available pre-Ember 2.0 is the {{component}} . With its help, we can clean up our template logic.
Read more >components-helper - npm
Start using components-helper in your project by running `npm i components-helper`. There is 1 other project in the npm registry using ...
Read more >In a helper function, is there a way to reference the component ...
controller.js ({ doSth: function(component, event, helper) { helper.helperFunction(component, event, helper); } }). helper.js
Read more >Understand helper components - Oracle Help Center
Widgets can reference helper components exposed by the application, such as those provided in the /react-components directory, or custom components that are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
IMO all the text should be written in sentence case and we should use something like
title
to convert the text to title case on macOS.Yep @say25! We could even define
toPlatformCase
as: