-
Notifications
You must be signed in to change notification settings - Fork 330
feat(color-select-panel): linear-gradient #3738
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c734480
feat(color-select-panel): linear-gradient
GaoNeng-wWw f13fbea
feat(color-select-panel): alpha
GaoNeng-wWw cead7f9
feat(color-select-panel): history
GaoNeng-wWw 013de62
feat(color-select-panel): predefine color
GaoNeng-wWw 8a303cf
fix(color-select-panel): linearGradient -> state.linearGradient
GaoNeng-wWw a237f6c
feat(color-select-panel): deg input
GaoNeng-wWw c0a71f8
refactor(color-select-panel): linear-gradient renderless
GaoNeng-wWw 8e08202
refactor(color-picker-panel): return undefined not 0 in useEvent
GaoNeng-wWw d98b012
docs(color-select-panel): api doc
GaoNeng-wWw 9583f7a
refactor(color-select-panel): remove unused less variable
GaoNeng-wWw b4b57f3
docs(color-select-panel): update api doc
GaoNeng-wWw dfd6e0b
docs(color-select-panel): add stable version meta
GaoNeng-wWw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
examples/sites/demos/pc/app/color-select-panel/linear-gradient-composition-api.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <script lang="ts" setup> | ||
| import { TinyColorSelectPanel, TinyButton } from '@opentiny/vue' | ||
| import { ref } from 'vue' | ||
|
|
||
| const color = ref('linear-gradient(120deg, hsla(334, 80%, 40%, 0.32) 0%,#F48FA2FF 96%)') | ||
| const visible = ref(false) | ||
| const history = ref(['linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)']) | ||
| const predefineColor = ref(['#66ccff']) | ||
| const changeVisible = () => { | ||
| visible.value = !visible.value | ||
| } | ||
| const onConfirm = () => { | ||
| hidden() | ||
| } | ||
| const hidden = () => { | ||
| visible.value = false | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <div> | ||
| <tiny-button @click="changeVisible">Show Color select panel</tiny-button> | ||
| <div style="position: relative"> | ||
| <tiny-color-select-panel | ||
| alpha | ||
| color-mode="linear-gradient" | ||
| v-model="color" | ||
| :visible="visible" | ||
| @confirm="onConfirm" | ||
| @cancel="hidden" | ||
| enable-predefine-color | ||
| :predefine="predefineColor" | ||
| enable-history | ||
| :history="history" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </template> |
71 changes: 71 additions & 0 deletions
71
examples/sites/demos/pc/app/color-select-panel/linear-gradient.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| test('线性渐变', async ({ page }) => { | ||
| await page.goto('color-select-panel#linear-gradient') | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| expect(await page.locator('.tiny-color-select-panel__linear-gradient__thumb').count()).toBe(2) | ||
| await page.locator('.tiny-color-select-panel__linear-gradient__thumb').first().click() | ||
| await page.locator('.tiny-color-select-panel__linear-gradient').click() | ||
| await page.locator('.tiny-color-select-panel__linear-gradient > div:nth-child(2)').click() | ||
| }) | ||
|
|
||
| test('线性渐变 (历史记录)', async ({ page }) => { | ||
| await page.goto('color-select-panel#linear-gradient') | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await expect(page.locator('.tiny-color-select-panel__history__color-block')).toBeVisible() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(334, 80%, 40%, 0.32) 0%,#F48FA2FF 96%)' | ||
| ) | ||
| await page.locator('.tiny-color-select-panel__history__color-block').click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)' | ||
| ) | ||
| await page.getByRole('button', { name: '取消' }).click() | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(334, 80%, 40%, 0.32) 0%,#F48FA2FF 96%)' | ||
| ) | ||
| await page.locator('.tiny-color-select-panel__inner__hue-select').click() | ||
| await page.getByRole('button', { name: '确定' }).click() | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await page.locator('.tiny-color-select-panel__history__color-block').first().click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)' | ||
| ) | ||
| await page.getByRole('button', { name: '确定' }).click() | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)' | ||
| ) | ||
| await page.getByRole('button', { name: '确定' }).click() | ||
| }) | ||
|
|
||
| test('线性渐变 (预定义颜色)', async ({ page }) => { | ||
| await page.goto('color-select-panel#linear-gradient') | ||
|
|
||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(334, 80%, 40%, 0.32) 0%,#F48FA2FF 96%)' | ||
| ) | ||
| await page.locator('.tiny-color-select-panel__predefine__color-block').click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(180deg, #FFFFFFFF 0%,#66CCFFFF 100%)' | ||
| ) | ||
| await page.getByRole('button', { name: '确定' }).click() | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await page.locator('.tiny-color-select-panel__history__color-block').first().click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)' | ||
| ) | ||
| await page.locator('.tiny-color-select-panel__history > div:nth-child(2)').click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(180deg, #FFFFFFFF 0%,#66CCFFFF 100%)' | ||
| ) | ||
| await page.locator('.tiny-color-select-panel__history__color-block').first().click() | ||
| await page.getByRole('button', { name: '确定' }).click() | ||
| await page.locator('#linear-gradient').getByRole('button', { name: 'Show Color select panel' }).click() | ||
| await expect(page.getByLabel('示例', { exact: true }).getByRole('textbox')).toHaveValue( | ||
| 'linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)' | ||
| ) | ||
| await page.getByRole('button', { name: '确定' }).click() | ||
| }) |
45 changes: 45 additions & 0 deletions
45
examples/sites/demos/pc/app/color-select-panel/linear-gradient.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <script lang="ts"> | ||
| import { defineComponent } from 'vue' | ||
| import { ref } from 'vue' | ||
| import { TinyButton, TinyColorSelectPanel } from '@opentiny/vue' | ||
|
|
||
| export default defineComponent({ | ||
| components: { TinyButton, TinyColorSelectPanel }, | ||
| setup() { | ||
| const color = ref('linear-gradient(120deg, hsla(334, 80%, 40%, 0.32) 0%,#F48FA2FF 96%)') | ||
| const visible = ref(false) | ||
| const history = ref(['linear-gradient(120deg, hsla(201, 80%, 40%, 0.32) 0%,#8FF2F4FF 96%)']) | ||
| const predefineColor = ref(['#66ccff']) | ||
| const changeVisible = () => { | ||
| visible.value = !visible.value | ||
| } | ||
| const onConfirm = () => { | ||
| hidden() | ||
| } | ||
| const hidden = () => { | ||
| visible.value = false | ||
| } | ||
| return { color, visible, history, predefineColor, changeVisible, onConfirm, hidden } | ||
| } | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div> | ||
| <tiny-button @click="changeVisible">Show Color select panel</tiny-button> | ||
| <div style="position: relative"> | ||
| <tiny-color-select-panel | ||
| alpha | ||
| color-mode="linear-gradient" | ||
| v-model="color" | ||
| :visible="visible" | ||
| @confirm="onConfirm" | ||
| @cancel="hidden" | ||
| enable-predefine-color | ||
| :predefine="predefineColor" | ||
| enable-history | ||
| :history="history" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.