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 alignment of file list #993

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion lib/components/FilePicker/FileList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ tr.file-picker__row {
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
padding-inline: 14px 0;
border-bottom: none; // remove lines between elements

// checkbox is always fully left aligned
&:not(.row-checkbox) {
padding-inline: 14px 0;
}

// Make column "size" end aligned
&.row-size {
text-align: end;
padding-inline: 0 14px; // align with header
}
// column "name" already has the padding (the preview icon)
&.row-name {
padding-inline: 2px 0;
}
}
}
37 changes: 25 additions & 12 deletions lib/components/FilePicker/FileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
@update:checked="onSelectAll" />
</th>
<th :aria-sort="sortByName" class="row-name">
<NcButton
:wide="true"
type="tertiary"
data-test="file-picker_sort-name"
@click="toggleSortByName">
<template #icon>
<IconSortAscending v-if="sortByName === 'ascending'" :size="20" />
<IconSortDescending v-else-if="sortByName === 'descending'" :size="20" />
<span v-else style="width: 44px" />
</template>
{{ t('Name') }}
</NcButton>
<div class="header-wrapper">
<span class="file-picker__header-preview" />
<NcButton
:wide="true"
type="tertiary"
data-test="file-picker_sort-name"
@click="toggleSortByName">
<template #icon>
<IconSortAscending v-if="sortByName === 'ascending'" :size="20" />
<IconSortDescending v-else-if="sortByName === 'descending'" :size="20" />
<span v-else style="width: 44px" />
</template>
{{ t('Name') }}
</NcButton>
</div>
</th>
<th :aria-sort="sortBySize" class="row-size">
<NcButton :wide="true" type="tertiary" @click="toggleSortBySize">
Expand Down Expand Up @@ -214,6 +217,12 @@ const fileContainer = ref<HTMLDivElement>()

<style scoped lang="scss">
.file-picker {
&__header-preview {
width: 22px; // 32px - 16px padding of button + 6px padding in file list rows
height: 32px;
flex: 0 0 auto; // do not shrink or grow
}

&__files {
// ensure focus outlines are visible
margin: 2px;
Expand All @@ -232,6 +241,10 @@ const fileContainer = ref<HTMLDivElement>()
// ensure focus outline of buttons is visible
padding: 2px;

.header-wrapper {
display: flex;
}

&.row-checkbox {
width: 44px;
}
Expand Down
15 changes: 15 additions & 0 deletions lib/components/FilePicker/FileListIcon.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Icon styling of the file list row preview or fallback icon
* (leading icon on the name row and header)
*/
.file-picker__file-icon {
width: 32px;
height: 32px;
min-width: 32px;
min-height: 32px;
background-repeat: no-repeat;
background-size: contain;
// for the fallback
display: flex;
justify-content: center;
}
2 changes: 2 additions & 0 deletions lib/components/FilePicker/FilePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ export default {
// Auto fit height
min-height: 0;
flex: 1;
// align with navigation on smaller screens
padding-inline: 2px;
* {
box-sizing: border-box;
Expand Down
21 changes: 6 additions & 15 deletions lib/components/FilePicker/FilePreview.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div :style="canLoadPreview ? { backgroundImage: `url(${previewURL})`} : undefined"
:aria-label="t('Mime type {mime}', { mime: node.mime || t('unknown') })"
class="file-picker__file-icon">
:class="fileListIconStyles['file-picker__file-icon']">
<template v-if="!canLoadPreview">
<IconFile v-if="isFile" :size="20" />
<IconFolder v-else :size="20" />
Expand All @@ -18,6 +18,11 @@ import { t } from '../../utils/l10n'
import IconFile from 'vue-material-design-icons/File.vue'
import IconFolder from 'vue-material-design-icons/Folder.vue'

// CSS modules
import fileListIconStylesModule from './FileListIcon.module.scss'
// workaround for vue2.7 bug, can be removed with vue3
const fileListIconStyles = ref(fileListIconStylesModule)

const props = defineProps<{
node: Node
}>()
Expand All @@ -39,17 +44,3 @@ watch(previewURL, () => {
}
}, { immediate: true })
</script>

<style scoped lang="scss">
.file-picker__file-icon {
width: 32px;
height: 32px;
min-width: 32px;
min-height: 32px;
background-repeat: no-repeat;
background-size: contain;
// for the fallback
display: flex;
justify-content: center;
}
</style>
15 changes: 13 additions & 2 deletions lib/components/FilePicker/LoadingTableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<span />
</td>
<td class="row-name">
<span />
<div class="row-wrapper">
<span :class="fileListIconStyles['file-picker__file-icon']" />
<span />
</div>
</td>
<td class="row-size">
<span />
Expand All @@ -17,6 +20,8 @@
</template>

<script setup lang="ts">
import fileListIconStyles from './FileListIcon.module.scss'

defineProps<{
/**
* Does the filelist use the checkbox column
Expand Down Expand Up @@ -55,11 +60,17 @@ defineProps<{
animation: gradient 12s ease infinite;
}

.row-wrapper {
display: inline-flex;
align-items: center;
}

.row-checkbox span {
width: 24px;
}

.row-name span {
.row-name span:last-of-type {
margin-inline-start: 6px;
width: 130px;
}

Expand Down
6 changes: 5 additions & 1 deletion lib/global.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
declare const __TRANSLATIONS__: {locale: string, json: any}[]
declare const __TRANSLATIONS__: {locale: string, json: any}[]

// Allow css modules
declare module '*.module.css';
declare module '*.module.scss';
Loading
Loading