Skip to content

Commit

Permalink
fix: move toggleRuleView to page rules (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq authored Jul 17, 2024
1 parent 7b93bea commit 0fd797c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 34 deletions.
13 changes: 1 addition & 12 deletions app/components/NavBar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useTimeAgo } from '@vueuse/core'
import { filtersRules as filters, stateStorage } from '~/composables/state'
import { filtersRules as filters } from '~/composables/state'
import { useRouter } from '#app/composables/router'
import { isFetching, payload } from '~/composables/payload'
import { toggleDark } from '~/composables/dark'
Expand All @@ -22,10 +22,6 @@ function showDeprecated() {
if (router.currentRoute.value.path !== '/rules')
router.push('/rules')
}
function toggleRuleView() {
stateStorage.value.viewType = stateStorage.value.viewType === 'list' ? 'grid' : 'list'
}
</script>

<template>
Expand Down Expand Up @@ -78,13 +74,6 @@ function toggleRuleView() {
i-ph-sun-dim-duotone dark:i-ph-moon-stars-duotone ml1 text-xl op50 hover:op75
@click="toggleDark()"
/>
<button
title="Toggle Rule View"

:class="stateStorage.viewType === 'list' ? 'i-ph-list-duotone' : 'i-ph-grid-four-duotone'"
text-xl op50 lt-md:hidden hover:op75
@click="toggleRuleView()"
/>
<NuxtLink
href="https://github.com/eslint/config-inspector" target="_blank"
i-carbon-logo-github text-lg op50 hover:op75
Expand Down
2 changes: 1 addition & 1 deletion app/composables/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const stateStorage = useLocalStorage(
)

const bp = useBreakpoints(breakpointsTailwind)
const bpSm = bp.smallerOrEqual('md')
export const bpSm = bp.smallerOrEqual('md')

export const isGridView = computed(() => bpSm.value || stateStorage.value.viewType === 'grid')

Expand Down
63 changes: 42 additions & 21 deletions app/pages/rules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { debouncedWatch } from '@vueuse/core'
import { computed, ref } from 'vue'
import Fuse from 'fuse.js'
import { filtersRules as filters } from '~/composables/state'
import { bpSm, filtersRules as filters, stateStorage } from '~/composables/state'
import { payload } from '~/composables/payload'
const rules = computed(() => Object.values(payload.value.rules))
Expand Down Expand Up @@ -164,28 +164,49 @@ function resetFilters() {
</div>
</div>

<div flex="~ gap-2">
<div
flex="~ inline gap-2 items-center"
border="~ gray/20 rounded-full" bg-gray:10 px3 py1
>
<div i-ph-list-checks-duotone />
<span>{{ filtered.length }}</span>
<span op75>rules {{ isDefaultFilters ? 'enabled' : 'filtered' }}</span>
<span text-sm op50>out of {{ rules.length }} rules</span>
<div items-center justify-between md:flex>
<div flex="~ gap-2" lt-sm:flex-col>
<div
flex="~ inline gap-2 items-center"
border="~ gray/20 rounded-full" bg-gray:10 px3 py1
>
<div i-ph-list-checks-duotone />
<span>{{ filtered.length }}</span>
<span op75>rules {{ isDefaultFilters ? 'enabled' : 'filtered' }}</span>
<span text-sm op50>out of {{ rules.length }} rules</span>
</div>
<button
v-if="!isDefaultFilters"
flex="~ inline gap-2 items-center self-start"
border="~ purple/20 rounded-full" bg-purple:10 px3 py1
@click="resetFilters()"
>
<div i-ph-funnel-duotone text-purple />
<span op50>Clear Filter</span>
<button
i-ph-x ml--1 text-sm op25 hover:op100
/>
</button>
</div>
<button
v-if="!isDefaultFilters"
flex="~ inline gap-2 items-center"
border="~ purple/20 rounded-full" bg-purple:10 px3 py1
@click="resetFilters()"
>
<div i-ph-funnel-duotone text-purple />
<span op50>Clear Filter</span>

<div v-if="!bpSm" flex="~ gap-1">
<button
i-ph-x ml--1 text-sm op25 hover:op100
/>
</button>
btn-action
:class="{ 'btn-action-active': stateStorage.viewType === 'list' }"
@click="stateStorage.viewType = 'list'"
>
<div i-ph-list-duotone />
List
</button>
<button
btn-action
:class="{ 'btn-action-active': stateStorage.viewType === 'grid' }"
@click="stateStorage.viewType = 'grid'"
>
<div i-ph-grid-four-duotone />
Grid
</button>
</div>
</div>
<RuleList
my4
Expand Down

0 comments on commit 0fd797c

Please sign in to comment.