forked from koel/koel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: shuffle all button disappear on phone (closes koel#1488)
- Loading branch information
Showing
13 changed files
with
33 additions
and
191 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
160 changes: 0 additions & 160 deletions
160
resources/assets/js/components/screens/__snapshots__/AllSongsScreen.spec.ts.snap
This file contains 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 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
8 changes: 4 additions & 4 deletions
8
resources/assets/js/components/ui/ScreenControlsToggle.spec.ts
This file contains 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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import isMobile from 'ismobilejs' | ||
import { expect, it } from 'vitest' | ||
import { fireEvent } from '@testing-library/vue' | ||
import { fireEvent, getByRole } from '@testing-library/vue' | ||
import UnitTestCase from '@/__tests__/UnitTestCase' | ||
import ScreenControlsToggle from './ScreenControlsToggle.vue' | ||
|
||
new class extends UnitTestCase { | ||
protected test () { | ||
it('renders and emits an event on mobile', async () => { | ||
isMobile.phone = true | ||
const { emitted, getByTestId } = this.render(ScreenControlsToggle) | ||
const { emitted, getByRole } = this.render(ScreenControlsToggle) | ||
|
||
await fireEvent.click(getByTestId('controls-toggle')) | ||
await fireEvent.click(getByRole('checkbox')) | ||
|
||
expect(emitted().toggleControls).toBeTruthy() | ||
expect(emitted()['update:modelValue']).toBeTruthy() | ||
}) | ||
} | ||
} |
27 changes: 20 additions & 7 deletions
27
resources/assets/js/components/ui/ScreenControlsToggle.vue
This file contains 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 |
---|---|---|
@@ -1,21 +1,34 @@ | ||
<template> | ||
<span v-if="isMobile.phone" class="text-highlight" data-testid="controls-toggle" @click="$emit('toggleControls')"> | ||
<icon v-if="showingControls" :icon="showingControls ? faAngleUp : faAngleDown" class="toggle"/> | ||
</span> | ||
<label v-if="isMobile.phone" class="text-highlight"> | ||
<input type="checkbox" v-model="value"/> | ||
<icon :icon="value ? faAngleUp : faAngleDown" class="toggle"/> | ||
<span>Toggle the song list controls</span> | ||
</label> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { faAngleDown, faAngleUp } from '@fortawesome/free-solid-svg-icons' | ||
import isMobile from 'ismobilejs' | ||
import { toRefs } from 'vue' | ||
import { computed } from 'vue' | ||
const props = withDefaults(defineProps<{ showingControls?: boolean }>(), { showingControls: true }) | ||
const { showingControls } = toRefs(props) | ||
const props = withDefaults(defineProps<{ modelValue?: boolean }>(), { modelValue: false }) | ||
const emit = defineEmits(['update:modelValue']) | ||
const value = computed({ | ||
get: () => props.modelValue, | ||
set: value => emit('update:modelValue', value) | ||
}) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.toggle { | ||
label { | ||
font-size: 1rem; | ||
display: inline-block; | ||
margin-left: 4px; | ||
} | ||
input, span { | ||
display: none; | ||
} | ||
</style> |
Oops, something went wrong.