decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Support prefix & suffix for 3 widgets: string, number & boolean

Open ngdangtu-vn opened this issue 1 year ago • 15 comments

This changes are about:

  • refactor syntax BooleanControl static properties
  • add prefix & suffix options
  • update widget control style to match with new options
  • update Boolean widget document

Summary

The update allows developers to display messages before (prefix) and after (suffix) the toggle. This design intends to provide a better information and look to users.

In my use case, I have a field to decide if I want to show a post in homepage. If I set "Show in homepage" string in label, the layout of input would be unbalance as the top small part is bigger than the main body. The toggle itself seems lonely as well. So if I can set "Visibility" in label option and "Show in homepage" in prefix option, it would be much sense.

Test plan

  1. Run yarn start
  2. Go to this path collections/kitchenSink/entries/a-big-entry-with-all-the-things
  3. Expect to see the exact Boolean input like this screenshot:
    image

Checklist

  • [x] I have read the contribution guidelines.

A picture of a cute animal (not mandatory but encouraged)

Be hold! The amazing meowman!

meow

ngdangtu-vn avatar Jul 07 '23 17:07 ngdangtu-vn

@ngdangtu-vn I see why you would want this feature, but it seems very similar to hint, which exists on all widgets and can be used to explain a field in more detail. Is there a reason why you wouldn't use hint?

martinjagodic avatar Jul 26 '23 07:07 martinjagodic

Is there a reason why you wouldn't use hint?

I wouldn't say I don't use hint. But my reason is simply:

  • Not wasting a whole line for only 1 toggle element
  • Hint text is small enough to be a hint only. Prefix/Suffix will plays nice the the role of important instruction.
  • In some messages, it looks better with prefix (or|and) suffix as well. I admit, my example wasn't very good. Maybe like this: Show author [x].

I even plan to do take this further to string and number widgets so dev can display fields like this [...]px. Cool right?

ngdangtu-vn avatar Aug 04 '23 17:08 ngdangtu-vn

Extending this to string and number will be useful! Can you implement that as part of this PR and I will review/merge it all together?

martinjagodic avatar Aug 07 '23 09:08 martinjagodic

Update photo for recent commits

String Widget

Number Widget

Boolean Widget

@martinjagodic Could you review my code and the Widgets' UI? Thanks.

ngdangtu-vn avatar Aug 08 '23 09:08 ngdangtu-vn

@xaiki

Thanks for your review but I'm not sure if they still need this PR. It kinda a dead PR already.

ngdangtu-vn avatar Oct 05 '23 01:10 ngdangtu-vn

@xaiki thanks for your reviews

@ngdangtu-vn This PR is not dead, but I understand it sitting here for a long time now. We have quite a backlog and we want to add features based on the triage we decided upon. This one is not essential so it will probably wait a bit longer.

martinjagodic avatar Oct 05 '23 07:10 martinjagodic

@martinjagodic Ok it's cool, I thought the code won't be able to fit with the new Decap.

@xaiki So I will fix the PR using your advice later 'cause I'm bit busy recently & I need time to reload my memory :))

ngdangtu-vn avatar Oct 05 '23 07:10 ngdangtu-vn

@martinjagodic if reviews help I'm happy to look at other PRs, just point me to the top of the stack.

xaiki avatar Oct 05 '23 07:10 xaiki

@xaiki I will happily assign you review requests. To talk more in-depth about what to do next, please join the contributing channel on our Discord server.

martinjagodic avatar Oct 05 '23 08:10 martinjagodic

@ngdangtu-vn are you still interested in moving this forward? If yes, please address the comments and solve merge conflicts. Thanks!

martinjagodic avatar Oct 18 '23 12:10 martinjagodic

Ok, give me around 2 more days

ngdangtu-vn avatar Oct 18 '23 15:10 ngdangtu-vn

Deploy request for cms-demo rejected.

Name Link
Latest commit e9c3a9ed5d273b6c048f655eac48b7208459196a

netlify[bot] avatar Oct 20 '23 08:10 netlify[bot]

I didn't close this? Hold on I'm reorganizing this... Maybe because I reset branch?

ngdangtu-vn avatar Oct 20 '23 09:10 ngdangtu-vn

@ngdangtu-vn maybe. I guess you can just reopen and continue from there.

martinjagodic avatar Oct 20 '23 09:10 martinjagodic

Deploy Preview for decap-www ready!

Name Link
Latest commit 2d9cb89683c74eb034cb4a00f54bbb97705070f9
Latest deploy log https://app.netlify.com/sites/decap-www/deploys/659c01c495853c00082824a5
Deploy Preview https://deploy-preview-6836--decap-www.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Jan 08 '24 14:01 netlify[bot]