-
Notifications
You must be signed in to change notification settings - Fork 489
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
Feat: Percentage field color customization #692
Feat: Percentage field color customization #692
Conversation
* develop: bump version number tests: fix firestore not authenticating fix rowActions expecting ID- sorted rows from db
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
fce32f4
to
13db993
Compare
Hi @htuerker! I'm Tina, the designer here at Rowy. From a design standpoint, I have a couple of minor comments.
Thanks again for contributing to Rowy! We're an open-source community because of the awesome things people like you are able to add 😄 |
This comment was marked as outdated.
This comment was marked as outdated.
Hi @htuerker!
🥳 This is much clear-er! I definitely like the version with the padding. My one tid-bit is if it would make more sense to keep the right angles at each corner of the actual color picker. I ask because aaaallll the way to the bottom-left would be black, #000, but would aaaallll the way to the top-left be white, #fff? I would imagine it might be slightly off white with the rounded corner there, though the hex code would tell me if that was the right assumption. But that also makes me wonder if there are some colors missing in those corners 🤔 Otherwise though, the color picker being encapsulated in the same rounded corner container is awesome!
💯 Perfect!
Of course, thank you for contributing! We hope you learned lots and got as much out of it as we did. I'll discuss pulling this with the team soon. Looking forward to any other contributions you make! |
this is looking pretty cool! , instead of start/end colors, what about min/max colors? |
Hi @htuerker, this is a cracking PR! I work primarily on Rowy’s frontend and was the one who implemented the side drawer color picker you’re extending. The only concern I have with this implementation is that you set the data structure for this config to be fixed to three items, start, mid, and end. I think it would be better to store it as an array of values instead, so we’re not constrained to only ever supporting 3 colors at most. Then, the UI could be expanded in the future to support multiple color stops like a gradient editor in a design tool. Although the stops would be equidistant for simplicity. Supporting more than 3 colors would require the Additionally, if you store a CSS-compatible color in the config UI, like a hex or rgba (if supporting alpha) string, then you don’t need to import colord to convert it to a hex string in the table cell components. For the config UI itself, I would suggest two changes:
You can keep the BasicCell component, but remove the coloring for it, so that a value still appears on scroll, instead of displaying And just a side note on the design for the color picker: it was meant to appear as one large rounded rectangle when opened, which is why the top corners of the react-color-palette UI are not rounded. This also removes the issue with parts of the color canvas being cut off by the rounded corners. It appears that the styles are being overridden somewhere, or I could have copied the wrong styles, because the bottom corner radii don’t match the collapsed box ( Ideally, it would closely match the design of other dropdown pickers like single and multi select, but those use a That may also be a workaround to the issue with dynamic resizing—just set it to a fixed size all the time, like with the current date pickers (the MUI component isn’t easily resizable). The side drawer color picker is fixed at 440px, I believe. I quite like the approach you took to bring out |
Hi @htuerker, Those changes look great! Except I might have not been clear with the color palette corners. I was trying to show in the image that we should keep them at right angles as to prevent any missing colors. See below: Otherwise, it looks awesome to me! @notsidney can speak for the bugs and misbehaviors much better than I can. |
Hi @notsidney, Just wanted to add here that the suggestion to separate the color picker from being directly adjacent to the drop down was by me 😅. The color picker felt a bit "cut off" when positioned there in my perspective. Additionally the actual circle indicator overlaps with some of the drop down when choosing a color at the top of the palette, as in your screenshot. So that is probably why some of the style changed and the color picker ended up getting some rounded corners. Just wanted to add my two cents, I'll let you take it from here. I'm sure you know what is better design consistency wise! |
Hi @htuerker, to be clear, this is what we need to see to be able to merge this PR:
The other comments I had I’ll leave to you to think about :) |
This comment was marked as off-topic.
This comment was marked as off-topic.
@notsidney I guess this is fine now! What a good first issue 😅 Last improvements:
|
boxShadow: (theme) => | ||
`0 0 0 1px ${theme.palette.divider} inest`, | ||
boxShadow: `0 0 0 1px ${theme.palette.divider} inest`, | ||
backgroundColor: | ||
typeof value === "number" | ||
? resultColorsScale(value).toHex() + "!important" | ||
? resultColorsScale( |
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.
Just note that in the MUI sx
prop, you can pass in a function with theme
as the first argument to access the theme object for any CSS property, so you didn’t need to change the boxShadow
definition here or use useTheme
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 did this change because I used the theme variable for the backgroundColor as well.
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.
Yes, I meant you could do the same thing for backgroundColor
as well: backgroundColor: (theme) => ...
src/components/ColorPickerInput.tsx
Outdated
const debouncedOnChangeComplete = useDebouncedCallback((color) => { | ||
handleOnChangeComplete(color); | ||
}, 100); | ||
|
||
useEffect(() => { | ||
debouncedOnChangeComplete(localValue); | ||
}, [debouncedOnChangeComplete, localValue]); |
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’m not sure why this is done this way. react-color-picker already has a onChangeComplete
prop fired on mouseup. Then you can avoid debouncing and using an effect.
If you need to debounce (when writing to db), it should be handled in the parent component. If the reason for debounce is to improve performance, you can use React 18’s startTransition
const debouncedOnChangeComplete = useDebouncedCallback((color) => { | |
handleOnChangeComplete(color); | |
}, 100); | |
useEffect(() => { | |
debouncedOnChangeComplete(localValue); | |
}, [debouncedOnChangeComplete, localValue]); |
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.
The problem here is every color changes frame(100 times+ just for a little drag) appends lots of styles into head as we're generating styles regarding. I'm aware of this problem for now. This also makes hard to reuse this component I already tried it for Color field.
I'm actually planning to work on another related issue after this. I've decided to think through this reusability problems during slider customization implementation. I'll research how we can use startTransition btw.
Also, a similar implementation used in Color field's PopoverCell.
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.
The problem here is every color changes frame(100 times+ just for a little drag)
It only re-renders this ColorPickerInput component, which is expected and necessary. This is why we use onChangeComplete
to save the selected color only when the user has stopped interacting with the picker, and then update the other components like preview.
appends lots of styles into head as we're generating styles regarding.
This only happens when the user stops dragging (onChangeComplete
), and MUI only appends styles to head in development mode. Notice that in dev mode, there are 1000+ nodes of <style data-emotion="mui" data-s>
but these do not appear in production (like demo.rowy.io). So this isn’t a problem.
Also, a similar implementation used in Color field's PopoverCell.
This is because when onChangeComplete
is called there, it immediately writes to the database, and we need to debounce writes for that since the user pays for writes. In this case, it’s all local, so we don’t have to add a debounce.
Additionally, now that you’ve accepted the suggestion to pass onChangeComplete
directly, you’ve made this debounce + effect redundant. Adding logs, I saw that:
- It fired when the dropdown is first opened.
- It fired when the user stopped moving the mouse, but is still holding down the mouse button.
- It fired when the user stopped holding the mouse button (this is the only time we want to fire), but since we already have an
onChangeComplete
prop,onChangeComplete
is called twice at this point.
I’ve added another change request and when you click accept on that in GitHub, I’ll merge this PR.
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 obviously better!
src/components/ColorPickerInput.tsx
Outdated
handleOnChangeComplete: (color: Color) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
export default function ColorPickerInput({ | ||
value, | ||
handleOnChangeComplete, |
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.
handleOnChangeComplete: (color: Color) => void; | |
disabled?: boolean; | |
} | |
export default function ColorPickerInput({ | |
value, | |
handleOnChangeComplete, | |
onChangeComplete: ColorPickerProps['onChangeComplete']; | |
disabled?: boolean; | |
} | |
export default function ColorPickerInput({ | |
value, | |
onChangeComplete, |
Pass the onChangeComplete
prop to the <ColorPicker>
component directly. You also need to import ColorPickerProps
from react-color-palette.
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 a nice trick I did not know it, thanks!
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 it's better not to use this as onChangeComplete is optional in ColorPickerProps.
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 it's better not to use this as onChangeComplete is optional in ColorPickerProps.
You can use NonNullable<ColorPickerProps['onChangeComplete']>
(TypeScript docs)
Co-authored-by: Sidney Alcantara <[email protected]>
Co-authored-by: Sidney Alcantara <[email protected]>
Co-authored-by: Sidney Alcantara <[email protected]>
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 the last change required before I can merge this PR.
Co-authored-by: Sidney Alcantara <[email protected]>
* Bump ejs from 3.1.6 to 3.1.8 Bumps [ejs](https://github.com/mde/ejs) from 3.1.6 to 3.1.8. - [Release notes](https://github.com/mde/ejs/releases) - [Changelog](https://github.com/mde/ejs/blob/main/CHANGELOG.md) - [Commits](mde/ejs@v3.1.6...v3.1.8) --- updated-dependencies: - dependency-name: ejs dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * Bump minimist from 1.2.5 to 1.2.6 Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * Bump tmpl from 1.0.4 to 1.0.5 Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5. - [Release notes](https://github.com/daaku/nodejs-tmpl/releases) - [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5) --- updated-dependencies: - dependency-name: tmpl dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * Bump protobufjs from 6.11.2 to 6.11.3 Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 6.11.2 to 6.11.3. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/v6.11.3/CHANGELOG.md) - [Commits](protobufjs/protobuf.js@v6.11.2...v6.11.3) --- updated-dependencies: - dependency-name: protobufjs dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * fix(rich-text-editor): fix dark mode ui appearance (#696) * fix(rich-text-editor): fix dark mode ui appearance * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/components/RichTextEditor.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/theme/RichTextEditorDarkCSS.tsx Co-authored-by: Sidney Alcantara <[email protected]> * Update src/theme/RichTextEditorLightCSS.tsx Co-authored-by: Sidney Alcantara <[email protected]> * fix(rich-text-editor): add stylings to dropdown * fix(rich-text-editor): add toolbar stylings * fix(rich-text-editor): reset hover&focus bg Co-authored-by: Sidney Alcantara <[email protected]> * update date & time filter operators for clarity * Action field: prevent selecting self as required field (fixes ROWY-551) * Date & Time: only show date for date filters * move fullScreenButton to be shared, remove md settings * bundle-analyzer * Leaf icon: use mdi-material-ui * Feat: Percentage field color customization (#692) * feat(percentage-c11n): convert to table cell * feat(percentage-c11n): add logic to default configs * feat(percentage-c11n): add color picker to settings * feat(percentage-c11n): change default colors * feat(percentage-c11n): fix button text color * feat(percentage-c11n): add labels to settings * feat(percentage-c11n): add preview section * feat(percentage-c11n): fix cache issues with debouncing * feat(percentage-c11n): add width responsiveness to color picker * feat(percentage-c11n): fix responsiveness issues * feat(percentage-c11n): add checkbox, refactor a little * feat(percentage-c11n): convert data type to array * feat(percentage-c11n): refactor config states * feat(percentage-c11n): fix defaults * feat(percentage-c11n): add basic cell without bg * feat(percentage-c11n): remove collapse * feat(percentage-c11n): refactor checkStates * feat(percentage-c11n): add grid layout * feat(percentage-c11n): chore conventions * feat(percentage-c11n): add default theme color to sidedrawer * remove redundant fragment Co-authored-by: Sidney Alcantara <[email protected]> * fix text color in preview Co-authored-by: Sidney Alcantara <[email protected]> * fix: change state to derived state Co-authored-by: Sidney Alcantara <[email protected]> * fix: review suggestions * fix: remove redundant change call Co-authored-by: Sidney Alcantara <[email protected]> * fix(percentage-c11n): remove redundant dependencies Co-authored-by: Shams <[email protected]> Co-authored-by: Sidney Alcantara <[email protected]> * extend callable timeout to over 9minutes * fix timeout value * fix page loading with white screen while system is in dark mode * Revert "bundle-analyzer" This reverts commit dd214b9. * fix nav items not accessible with Tab * Percentage: don’t display if value null or undefined * fix NavDrawer causing compile to fail * show text field if collections array is empy * column ids * row ID * fix create table showing empty dropdown for collections * fix row not writing to db once all required fields are written Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Han Tuerker <[email protected]> Co-authored-by: shamsmosowi <[email protected]>
Hello! 👋
This fixes #518.
Changes I made in order:
Percentage
field fromBasicCell
toTableCell
.fields/Color/SideDrawerField
Settings
and add it to the fields config as required.Color
field, maybe we can try to use it there too.resultColorsScale
utility logic as I handled this by giving a defaultcolors
parameter. Everything works fine.emotion-cache
problems by debouncing the dynamic style changes with 8854965ColorPicker
container with fce32f4I'm pretty much new to the codebase. I'd love to get a little more informative review. I'll be able to work on possible change requests.
Change previews: