Skip to content
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

fix color-picker bug and update changelog #631

Merged
merged 45 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
55c322c
docs: update release notes (#397)
kagol Aug 17, 2023
b6e7939
fix Playground Page (#399)
shenjunjian Aug 17, 2023
194df1f
fix(sites): fix (#400)
shenjunjian Aug 17, 2023
8a972cf
feat(release): delete color-picker
zzcr Aug 17, 2023
060aab7
feat(release): delete color-picker
zzcr Aug 17, 2023
fe58760
feat(release): fix grid tips contentMethod
zzcr Aug 18, 2023
7a410e7
fix(playground): fix process.env \ changeVersion \sortablejs bugs (…
shenjunjian Aug 21, 2023
770149d
fix(sites): fix grid demo api link jump error url (#421)
gimmyhehe Aug 21, 2023
7162ac5
fix(form-demo): add form validateField api demo (#424)
gimmyhehe Aug 21, 2023
2f61b95
fix: fix demo import vue-modal; fix playground share (#428)
shenjunjian Aug 22, 2023
8dcf029
fix: import Modal (#430)
shenjunjian Aug 22, 2023
1f8ade7
fix(select): Fix label not displaying correctly when using optimizati…
MomoPoppy Aug 22, 2023
0da300c
fix(search): the enter bug of the search component is fixed (#439)
chenxi-20 Aug 23, 2023
056f12e
feat(release): fix grid watch data
zzcr Aug 24, 2023
898c45d
feat(grid): fix grid custom tooltip
zzcr Aug 24, 2023
f4c5973
fix: fix grid pager events
zzcr Aug 29, 2023
bdbb188
docs: fix the problem of missing container component style (#453)
kagol Aug 31, 2023
fbfa551
fix(checkbox): fix checkbox selected icon bug close #450 (#451)
gimmyhehe Aug 31, 2023
5dbb699
fix: fix input attrs id
zzcr Sep 1, 2023
3884661
fix(slider): fix slider range demo bug
zzcr Sep 1, 2023
44e4fc6
fix: fix when datetime component in dialog-box, the popper scroll awa…
shenjunjian Sep 3, 2023
279f336
fix(mobile-tabbar): fixed a tabbar component switchover issue on the …
chenxi-20 Sep 4, 2023
16dae49
fix(slider): fix upload destory bug
zzcr Sep 6, 2023
4d66cf2
fix(smb-theme): smb theme change fix (#469)
gimmyhehe Sep 8, 2023
b34bdb1
fix(checkbox): fix checkbox group wrap (#467)
gimmyhehe Sep 8, 2023
b42738d
fix(dropdown): Fix the issue of incorrect theme icons for Dropdown co…
MomoPoppy Sep 8, 2023
adf9d90
fix(dropdown-item): (#472)
MomoPoppy Sep 8, 2023
ea53ded
fix(button): button smb theme change fix (#470)
gimmyhehe Sep 8, 2023
ee5e6f5
fix(playground): fix jump to incorrect demo (#466)
gimmyhehe Sep 8, 2023
1d93f28
fix(link): smb theme change fix (#474)
gimmyhehe Sep 8, 2023
c485da2
fix(theme): smb theme change fix (#480)
gimmyhehe Sep 11, 2023
3e19c40
fix(grid): fix grid checkbox radio x-design theme
zzcr Sep 11, 2023
8bb8e4b
chore(ts): change code style for import ts type (#511)
gimmyhehe Sep 25, 2023
913342c
fix(Cascader, DropDown, Popeditor): fixed Cascader component panel no…
yoyo201626 Sep 25, 2023
460c5f6
fix(popper): fix popper element offset error in micro-app (#570)
gimmyhehe Oct 10, 2023
0feddf2
feat: update code
zzcr Oct 23, 2023
7b64c67
Merge branch 'dev' of github.com:opentiny/tiny-vue into release
zzcr Oct 23, 2023
06ac1b5
Merge branch 'dev' of github.com:opentiny/tiny-vue into release
zzcr Oct 23, 2023
eb366ad
Merge branch 'dev' of github.com:opentiny/tiny-vue into release
zzcr Oct 23, 2023
4863d34
fix(docs): add support vue2.7 docs (#630)
shenjunjian Oct 24, 2023
aeacb6f
fix: fix color-picker error
zzcr Oct 24, 2023
eb20bed
Merge branch 'release' of github.com:opentiny/tiny-vue into release
zzcr Oct 24, 2023
77f7125
docs: update changelog v3.11.0 (#629)
kagol Oct 24, 2023
9fac7c5
fix: update site version
zzcr Oct 24, 2023
485687a
Merge branch 'dev' of github.com:opentiny/tiny-vue into release
zzcr Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/react-site/scripts/build-react.mjs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function buildReact() {
lib: {
entry: entries,
formats: ['es'],
fileName: (format, entryName) => `${entryName}.js`
fileName: (_, entryName) => `${entryName}.js`
}
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<tiny-color-picker v-model="color" />
<tiny-button @click="changeColor"> 切换 </tiny-button>
<div>
<tiny-color-picker v-model="color" />
<tiny-button @click="changeColor"> 切换 </tiny-button>
</div>
</template>

<script>
Expand Down
399 changes: 277 additions & 122 deletions examples/sites/demos/pc/webdoc/changelog.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion examples/sites/demos/pc/webdoc/installation-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
| Vue2.x | @opentiny/vue@2.x |
| Vue3.x | @opentiny/vue@3.x |

Currently, TinyVue does not support Vue2.7. When the project uses the Vue2.0 framework, the recommended version format is `"vue": "~2.6.14", "vue-template-compiler": "~2.6.14"`.
**Vue2 Engineering Description**

For a long time, TinyVue only supports Vue 2.6.14. Starting from TinyVue 2.11.0, the project of Vue 2.7+ is also supported. Make sure that you have installed the correct Vue 2.x dependency.

### New Project Configuration

Expand Down
4 changes: 3 additions & 1 deletion examples/sites/demos/pc/webdoc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
| Vue2.x | @opentiny/vue@2.x |
| Vue3.x | @opentiny/vue@3.x |

`TinyVue` 暂时不支持 `Vue2.7`, 当项目使用`Vue2.0`框架时,推荐版本写法:`"vue": "~2.6.14" , "vue-template-compiler": "~2.6.14"` 。
**Vue2工程说明**

长期以来,TinyVue 都是只支持 Vue 2.6.14 版本。 从 TinyVue 2.11.0 开始,也支持 Vue 2.7+的工程了,请确保你安装了正确的Vue 2.x的依赖。

### 全新项目配置

Expand Down
2 changes: 1 addition & 1 deletion examples/sites/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/vue-docs",
"version": "2.1.32",
"version": "2.1.1",
"scripts": {
"start": "vite",
"start:saas": "vite --mode saas",
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Sun from './icons/Sun.vue'
import Moon from './icons/Moon.vue'
import Share from './icons/Share.vue'

const versions = ['3.10.0', '3.9.1', '3.8.4']
const versions = ['3.11', '3.10', '3.9', '3.8']
const latestVersion = versions[0]
const cdnHost = 'https://unpkg.com'
window.localStorage.setItem('setting-cdn', cdnHost)
Expand Down
2 changes: 1 addition & 1 deletion examples/vue3/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare module '*.vue' {
}

interface ImportMetaEnv {
readonly VITE_AUI_MODE: 'pc' | 'mobile' | 'mobile-first'
readonly VITE_TINY_MODE: 'pc' | 'mobile' | 'mobile-first'
// 更多环境变量...
}

Expand Down
2 changes: 1 addition & 1 deletion internals/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"esno": "^0.16.3",
"fast-glob": "^3.2.12",
"rollup-plugin-replace": "^2.2.0",
"vite-plugin-dts": "^3.0.0",
"vite-plugin-dts": "~3.0.0",
"vite-plugin-svgr": "^3.2.0",
"vite-svg-loader": "^3.6.0"
}
Expand Down
14 changes: 6 additions & 8 deletions packages/renderless/src/color-picker/alpha-select/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import type { IColorSelectPanel } from "@/types";
import type { IColorSelectPanel } from '@/types'

export const calcLeftByAlpha = (wrapper: HTMLElement, thumb: HTMLElement, alpha: number) => {
return Math.round(
(alpha * (wrapper.offsetWidth - thumb.offsetWidth / 2)) / 100
)
return Math.round((alpha * (wrapper.offsetWidth - thumb.offsetWidth / 2)) / 100)
}

export const updateThumb = (alpha: number, thumb: HTMLElement, wrapper: HTMLElement) => {
thumb.style.left = `${calcLeftByAlpha(wrapper, thumb, alpha)}px`
}

export const onDrag = (
event: MouseEvent, bar: IColorSelectPanel<HTMLElement>, thumb: IColorSelectPanel<HTMLElement>,
event: MouseEvent,
bar: IColorSelectPanel<HTMLElement>,
thumb: IColorSelectPanel<HTMLElement>,
alpha: IColorSelectPanel<number>
) => {
const rect = bar.value.getBoundingClientRect()
const { clientX } = event
let left = clientX - rect.left
left = Math.max(thumb.value.offsetWidth / 2, left)
left = Math.min(left, rect.width - thumb.value.offsetWidth / 2)
alpha.value = Math.round(
((left - thumb.value.offsetWidth / 2) / (rect.width - thumb.value.offsetWidth)) * 100
)
alpha.value = Math.round(((left - thumb.value.offsetWidth / 2) / (rect.width - thumb.value.offsetWidth)) * 100)
}
24 changes: 13 additions & 11 deletions packages/renderless/src/color-picker/alpha-select/vue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IColorPickerRef as Ref} from '@/types';
import { IColorPickerRef as Ref } from '@/types'
import Color from '../utils/color'
import { draggable } from '../utils/use-drag'
import { onDrag, updateThumb } from '.'
Expand All @@ -16,13 +16,16 @@ export const renderless = (props, context, { emit }) => {
const alphaWrapper: Ref<HTMLElement> = context.ref()
const alphaThumb: Ref<HTMLElement> = context.ref()
const alpha = context.ref(color.get('a'))
context.watch(() => props.color, (hex: string) => {
color.reset(hex)
const [rr, gg, bb] = color.getRGB()
r.value = rr
g.value = gg
b.value = bb
})
context.watch(
() => props.color,
(hex: string) => {
color.reset(hex)
const [rr, gg, bb] = color.getRGB()
r.value = rr
g.value = gg
b.value = bb
}
)
context.watch(alpha, (newAlpha) => {
updateThumb(newAlpha, alphaThumb.value, alphaWrapper.value)
emit('alpha-update', alpha.value)
Expand All @@ -36,10 +39,9 @@ export const renderless = (props, context, { emit }) => {
})
const api = {
state,
color: props.color,
slider,
alphaWrapper,
alphaThumb,
alphaThumb
}
context.onMounted(() => {
updateThumb(alpha.value, alphaThumb.value, slider.value)
Expand All @@ -49,7 +51,7 @@ export const renderless = (props, context, { emit }) => {
},
start(event) {
onDrag(event as MouseEvent, slider, alphaThumb, alpha)
},
}
})
})
return api
Expand Down
52 changes: 26 additions & 26 deletions packages/renderless/src/color-picker/color-select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,49 @@ export const setPosition = (el: HTMLElement, x: number, y: number) => {
}
export const getXBySaturation = (s: number, width: number) => (s * width) / 100
export const getYByLight = (l: number, height: number) => ((100 - l) * height) / 100
export const updatePosition = (event: MouseEvent | TouchEvent, rect: DOMRect, cursor: IColorSelectPanel<HTMLElement>) => {
export const updatePosition = (
event: MouseEvent | TouchEvent,
rect: DOMRect,
cursor: IColorSelectPanel<HTMLElement>
) => {
let x = (event as MouseEvent).clientX - rect.left
let y = (event as MouseEvent).clientY - rect.top
x = Math.max(0, x)
x = Math.min(x, rect.width)
y = Math.max(0, y)
y = Math.min(y, rect.height)

setPosition(cursor.value, x - 1 / 2 * cursor.value.offsetWidth, y - 1 / 2 * cursor.value.offsetWidth)
setPosition(cursor.value, x - (1 / 2) * cursor.value.offsetWidth, y - (1 / 2) * cursor.value.offsetWidth)
return { x, y }
}
export const calcSaturation = (x: number, width: number) => (x / width)
export const calcSaturation = (x: number, width: number) => x / width
export const calcBrightness = (y: number, height: number) => 100 - (y / height) * 100
export const getThumbTop = (wrapper: HTMLElement, thumb: HTMLElement, hue: number) => {
return Math.round(
(hue * (wrapper.offsetHeight - thumb.offsetHeight / 2)) / 360
)
return Math.round((hue * (wrapper.offsetHeight - thumb.offsetHeight / 2)) / 360)
}

export const resetCursor = (
s: number, v: number,
s: number,
v: number,
wrapper: IColorSelectPanel<HTMLElement>,
cursor: IColorSelectPanel<HTMLElement>,
thumb: IColorSelectPanel<HTMLElement>,
color: Color, h: IColorSelectPanel<number>
color: Color,
h: IColorSelectPanel<number>
) => {
const { width, height } = wrapper.value.getBoundingClientRect()
const x = getXBySaturation(s, width) - 1 / 2 * cursor.value.offsetWidth
const y = getYByLight(v, height) - 1 / 2 * cursor.value.offsetWidth
const x = getXBySaturation(s, width) - (1 / 2) * cursor.value.offsetWidth
const y = getYByLight(v, height) - (1 / 2) * cursor.value.offsetWidth
setPosition(cursor.value, x < 0 ? 0 : x, y < 0 ? 0 : y)
const thummbTop = getThumbTop(wrapper.value, thumb.value, color.get('h'))
thumb.value.style.top = `${thummbTop}px`
h.value = color.get('h')
}

export const updateCursor = (wrapper: IColorSelectPanel<HTMLElement>, cursor: IColorSelectPanel<HTMLElement>, emit) => {
return (color: Color, event: MouseEvent)=>{
const rect = wrapper.value.getBoundingClientRect();
const {x,y} = updatePosition(event, rect, cursor)
return (color: Color, event: MouseEvent) => {
const rect = wrapper.value.getBoundingClientRect()
const { x, y } = updatePosition(event, rect, cursor)
color.set({
s: calcSaturation(x, rect.width) * 100,
v: calcBrightness(y, rect.height)
Expand All @@ -63,18 +67,14 @@ export const updateThumb = (
h: IColorSelectPanel<Number>,
emit
) => {
return (event: MouseEvent)=>{
return (event: MouseEvent) => {
const e = event as MouseEvent
const rect = bar.value.getBoundingClientRect()
let top = e.clientY - rect.top
top = Math.min(top, rect.height - thumb.value.offsetHeight / 2)
top = Math.max(thumb.value.offsetHeight / 2, top)
thumb.value.style.top = `${top}px`
h.value = Math.round(
((top - thumb.value.offsetHeight / 2) /
(rect.height - thumb.value.offsetHeight)) *
360
)
emit('hue-update', h.value)
const rect = bar.value.getBoundingClientRect()
let top = e.clientY - rect.top
top = Math.min(top, rect.height - thumb.value.offsetHeight / 2)
top = Math.max(thumb.value.offsetHeight / 2, top)
thumb.value.style.top = `${top}px`
h.value = Math.round(((top - thumb.value.offsetHeight / 2) / (rect.height - thumb.value.offsetHeight)) * 360)
emit('hue-update', h.value)
}
}
}
44 changes: 17 additions & 27 deletions packages/renderless/src/color-picker/color-select/vue.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {IColorSelectPanel as Ref} from '@/types';
import { IColorSelectPanel as Ref } from '@/types'
import { draggable } from '../utils/use-drag'
import Color from '../utils/color'
import {
getThumbTop,
resetCursor,
updateThumb,
updateCursor,
} from './index'
import { getThumbTop, resetCursor, updateThumb, updateCursor } from './index'

export const api = ['state', 'cursor', 'wrapper', 'bar', 'thumb']
export const renderless = (props, context, { emit }) => {
Expand All @@ -24,40 +19,35 @@ export const renderless = (props, context, { emit }) => {
background
})
const api = { state, cursor, wrapper, bar, thumb }
context.watch(() => props.color, (newColor) => {
color.reset(newColor)
resetCursor(color.get('s'), color.get('v'), wrapper, cursor, thumb, color, h)
})
context.watch(
() => props.color,
(newColor) => {
color.reset(newColor)
resetCursor(color.get('s'), color.get('v'), wrapper, cursor, thumb, color, h)
}
)
context.onMounted(() => {
const update = {
thumb: updateThumb(bar, thumb, h, emit),
cursor: updateCursor(wrapper,cursor,emit)
};
cursor: updateCursor(wrapper, cursor, emit)
}
const thumbTop = getThumbTop(wrapper.value, thumb.value, h.value)
thumb.value.style.top = `${thumbTop}px`
resetCursor(
color.get('s'),
color.get('v'),
wrapper,
cursor,
thumb,
color,
h
)
resetCursor(color.get('s'), color.get('v'), wrapper, cursor, thumb, color, h)
draggable(wrapper.value, {
drag(event) {
update.cursor(color, event as MouseEvent);
update.cursor(color, event as MouseEvent)
},
start(event) {
update.cursor(color, event as MouseEvent);
},
update.cursor(color, event as MouseEvent)
}
})
draggable(bar.value, {
drag(event) {
update.thumb(event as MouseEvent)
},
start(event){
update.thumb(event as MouseEvent);
start(event) {
update.thumb(event as MouseEvent)
}
})
})
Expand Down
21 changes: 14 additions & 7 deletions packages/renderless/src/color-picker/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {IColorPickerRef, IColorSelectPanelRef} from '@/types';
import { IColorPickerRef, IColorSelectPanelRef } from '@/types'
import type Color from './utils/color'

export const onConfirm = (
hex: IColorSelectPanelRef<string>, triggerBg: IColorSelectPanelRef<string>,
res: IColorSelectPanelRef<string>, emit, isShow: IColorSelectPanelRef<boolean>
hex: IColorSelectPanelRef<string>,
triggerBg: IColorSelectPanelRef<string>,
res: IColorSelectPanelRef<string>,
emit,
isShow: IColorSelectPanelRef<boolean>
) => {
return (color: string) => {
res.value=color;
res.value = color
hex.value = res.value
triggerBg.value = res.value
emit('confirm', res.value)
Expand All @@ -15,11 +18,15 @@ export const onConfirm = (
}

export const onCancel = (
res: IColorSelectPanelRef<string>, triggerBg: IColorSelectPanelRef<string>, emit, isShow: IColorSelectPanelRef<boolean>,
hex: IColorSelectPanelRef<string>, color: Color
res: IColorSelectPanelRef<string>,
triggerBg: IColorSelectPanelRef<string>,
emit,
isShow: IColorSelectPanelRef<boolean>,
hex: IColorSelectPanelRef<string>,
color: Color
) => {
return () => {
if (isShow.value){
if (isShow.value) {
res.value = triggerBg.value
hex.value = triggerBg.value
color.reset(hex.value)
Expand Down
9 changes: 7 additions & 2 deletions packages/renderless/src/color-picker/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ function hexToRgb(hex: string) {
const normalizeHexColor = (color: string) => {
let normalizedColor: string = color.replace('#', '')
if (normalizedColor.length === 3) {
normalizedColor = normalizedColor.split('').map(char => char + char).join('')
normalizedColor = normalizedColor
.split('')
.map((char) => char + char)
.join('')
}
normalizedColor = normalizedColor.padEnd(6, '0')

Expand Down Expand Up @@ -79,7 +82,9 @@ export default class Color {
if (!this.enableAlpha) {
return hsv(this.h, this.s, this.v).hex().toString()
}
return hsv(this.h, this.s, this.v, this.a / 100).hexa().toString()
return hsv(this.h, this.s, this.v, this.a / 100)
.hexa()
.toString()
}

/**
Expand Down
Loading