-
Notifications
You must be signed in to change notification settings - Fork 53
feat: add avatar editing support #2938
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
129 changes: 129 additions & 0 deletions
129
spx-gui/src/components/community/user/AvatarZoomSlider.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,129 @@ | ||
| <script setup lang="ts"> | ||
| import { UIIcon, UISlider } from '@/components/ui' | ||
|
|
||
| const props = withDefaults( | ||
| defineProps<{ | ||
| value: number | ||
| disabled?: boolean | ||
| min?: number | ||
| max?: number | ||
| step?: number | ||
| buttonStep?: number | ||
| }>(), | ||
| { | ||
| disabled: false, | ||
| min: 1, | ||
| max: 3, | ||
| step: 0.01, | ||
| buttonStep: 0.1 | ||
| } | ||
| ) | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'update:value': [number] | ||
| }>() | ||
|
|
||
| function handleValueUpdate(value: number) { | ||
| const nextValue = Number(Math.min(props.max, Math.max(props.min, value)).toFixed(2)) | ||
| if (nextValue === props.value) return | ||
| emit('update:value', nextValue) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="avatar-zoom-slider"> | ||
| <button | ||
| v-radar="{ name: 'Zoom out avatar button', desc: 'Click to zoom out the avatar image' }" | ||
| class="zoom-button" | ||
| type="button" | ||
| :disabled="props.disabled || props.value <= props.min" | ||
| @click="handleValueUpdate(props.value - props.buttonStep)" | ||
| > | ||
| <UIIcon class="zoom-icon" type="minus" /> | ||
| </button> | ||
|
|
||
| <UISlider | ||
| class="slider" | ||
| update-on="input" | ||
| :min="props.min" | ||
| :max="props.max" | ||
| :step="props.step" | ||
| :value="props.value" | ||
| :disabled="props.disabled" | ||
| :tooltip="false" | ||
| @update:value="handleValueUpdate" | ||
| /> | ||
|
|
||
| <button | ||
| v-radar="{ name: 'Zoom in avatar button', desc: 'Click to zoom in the avatar image' }" | ||
| class="zoom-button" | ||
| type="button" | ||
| :disabled="props.disabled || props.value >= props.max" | ||
| @click="handleValueUpdate(props.value + props.buttonStep)" | ||
| > | ||
| <UIIcon class="zoom-icon" type="plus" /> | ||
| </button> | ||
aofei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .avatar-zoom-slider { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| gap: 10px; | ||
| width: 366px; | ||
| height: 48px; | ||
| } | ||
|
|
||
| .slider { | ||
| flex: 1 1 auto; | ||
| min-width: 0; | ||
|
|
||
| &:deep(.n-slider-handle) { | ||
| background: transparent; | ||
| box-shadow: none; | ||
| } | ||
|
|
||
| &:deep(.n-slider-rail), | ||
| &:deep(.n-slider-rail__fill) { | ||
| height: 6px; | ||
| border-radius: 999px; | ||
| } | ||
| } | ||
|
|
||
| .slider:deep(.thumb) { | ||
| box-sizing: border-box; | ||
| box-shadow: | ||
| inset 0 0 0 2px var(--ui-color-primary-400), | ||
| 0 1px 2px rgb(36 41 47 / 10%); | ||
| } | ||
|
|
||
| .zoom-button { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| flex: 0 0 auto; | ||
| width: 24px; | ||
| height: 24px; | ||
| padding: 0; | ||
| border: none; | ||
| background: none; | ||
| color: var(--ui-color-grey-900); | ||
| cursor: pointer; | ||
|
|
||
| &:not(:disabled):hover { | ||
| color: var(--ui-color-grey-1000); | ||
| } | ||
|
|
||
| &:disabled { | ||
| color: var(--ui-color-grey-700); | ||
| cursor: not-allowed; | ||
| } | ||
| } | ||
|
|
||
| .zoom-icon { | ||
| width: 20px; | ||
| height: 20px; | ||
| } | ||
| </style> | ||
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.