-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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(color-picker): add color-preview
#1395
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/tusimple/naive-ui/J3FEaGSvhay5TcYxQf1xgR8hkGsX |
Codecov Report
@@ Coverage Diff @@
## main #1395 +/- ##
==========================================
- Coverage 52.96% 52.89% -0.07%
==========================================
Files 533 534 +1
Lines 13336 13354 +18
Branches 3807 3815 +8
==========================================
+ Hits 7063 7064 +1
- Misses 5151 5164 +13
- Partials 1122 1126 +4
Continue to review full report at Codecov.
|
function handleChange (e: Event): void { | ||
// hex | ||
const value = (e.target as HTMLInputElement).value | ||
props.onUpdateColor?.(value.toLocaleUpperCase()) |
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 toUpperCase
is enough, why you chose toLocaleUpperCase()
?
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.
You are right, I did not fully consider their usage scenarios, and I will replace it immediately.
CHANGELOG.en-US.md
Outdated
@@ -1,5 +1,9 @@ | |||
# CHANGELOG | |||
|
|||
### Feats | |||
|
|||
- Add `n-color-preview` component, closes [#1281](https://github.com/TuSimple/naive-ui/issues/1281). |
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.
Add a prop to controll whether to show the native color picker.
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.
And for preview
, should we always show it, or is it also controlled by prop.
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 okay to add a show-preview
prop.
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.
Sorry that there was no update yesterday due to work reasons. This feature is now complete, but I don’t know whether my description in the document is appropriate.
src/color-picker/src/ColorPicker.tsx
Outdated
showPreview: { | ||
type: Boolean, | ||
default: false | ||
}, |
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.
showPreview: { | |
type: Boolean, | |
default: false | |
}, | |
showPreview: Boolean, |
src/color-picker/src/utils.ts
Outdated
export function convertColor ( | ||
value: string, | ||
mode: ColorPickerMode, | ||
originalMode?: ColorPickerMode | null |
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.
originalMode?: ColorPickerMode | null | |
originalMode?: null |
outline: none; | ||
`, [ | ||
cE('fill', ` | ||
box-shadow: rgba(0, 0, 0, .15) 0px 0px 0px 1px inset, 0 0 4px var(--swatch-valid-color); |
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.
box-shadow: rgba(0, 0, 0, .15) 0px 0px 0px 1px inset, 0 0 4px var(--swatch-valid-color); | |
box-shadow: rgba(0, 0, 0, .15) 0px 0px 0px 1px inset, 0 0 4px var(--swatch-valid-color); |
What is --swatch-valid-color
? For unconfigurable mutable color using inline style is enough.
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 approach is to display a shadow with the same color as the background when the swatch is focused.
The combination of them has a good visual effect, but I didn’t think of a good way to keep their colors consistent.
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.
That's okay, keep it.
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.
I have thought about using color
and currentColor
before, but I want to reduce the dependency between CSS.
@@ -188,10 +218,18 @@ export default c([ | |||
cE('fill', ` | |||
width: 100%; | |||
height: 100%; | |||
background: var(--swatch-valid-color); |
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.
What is --swatch-valid-color?
@nooooooom rebase on the latest commit |
I will do it now. |
close #1281.