Skip to content

Commit

Permalink
Merge pull request #632 from dnum-mi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
laruiss authored Nov 8, 2023
2 parents 2370eeb + 5b92d7c commit 660e4d5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/components/DsfrButton/DsfrButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts" setup>
import { type Ref, computed, ref } from 'vue'
import { OhVueIcon as VIcon } from 'oh-vue-icons'
import { type CustomizeIconType } from 'oh-vue-icons'
// import '@gouvfr/dsfr/dist/component/button/button.module.js'
Expand All @@ -14,7 +13,7 @@ export type DsfrButtonProps = {
iconOnly?: boolean
noOutline?: boolean
size?: 'sm' | 'small' | 'lg' | 'large' | 'md' | 'medium' | '' | undefined
icon?: string | CustomizeIconType
icon?: string | InstanceType<typeof VIcon>['$props']
onClick?: ($event: MouseEvent) => void
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/DsfrFooter/DsfrFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ const aLicenceHref = computed(() => {
/>
</RouterLink>
<RouterLink
v-if="operatorImgSrc"
class="fr-footer__brand-link"
:to="operatorTo"
:title="operatorLinkText"
>
<img
v-if="operatorImgSrc"
class="fr-footer__logo fr-responsive-img"
:style="[
typeof operatorImgStyle === 'string' ? operatorImgStyle : '',
Expand Down
13 changes: 11 additions & 2 deletions src/components/DsfrModal/DsfrModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import { FocusTrap } from 'focus-trap-vue'
import DsfrButtonGroup from '../DsfrButton/DsfrButtonGroup.vue'
import { onMounted, onBeforeUnmount, computed, ref, nextTick, watch, Ref } from 'vue'
import { getRandomId } from '@/utils/random-utils'
const props = withDefaults(defineProps<{
modalId?: string
opened?: boolean
actions?: Record<string, any>[]
isAlert?: boolean
origin?: {focus:() => void}
title: string
icon?: string
}>(), {
modalId: () => getRandomId('modal', 'dialog'),
actions: () => [],
origin: () => ({ focus () {} }), // eslint-disable-line @typescript-eslint/no-empty-function
icon: undefined,
Expand All @@ -35,14 +38,18 @@ const closeBtn: Ref<HTMLButtonElement | null> = ref(null)
watch(() => props.opened, (newValue) => {
if (newValue) {
document.body.classList.add('modal-open')
modal.value?.showModal()
setTimeout(() => {
closeBtn.value?.focus()
}, 100)
} else {
document.body.classList.remove('modal-open')
modal.value?.close()
}
})
const modal = ref()
onMounted(() => {
startListeningToEscape()
})
Expand Down Expand Up @@ -72,10 +79,12 @@ async function close () {
>
<dialog
id="fr-modal-1"
aria-labelledby="fr-modal-title-modal-1"
ref="modal"
:aria-labelledby="modalId"
:role="role"
class="fr-modal"
:class="{'fr-modal--opened': opened}"
:open="opened"
>
<div class="fr-container fr-container--fluid fr-container-md">
<div class="fr-grid-row fr-grid-row--center">
Expand All @@ -97,7 +106,7 @@ async function close () {
</div>
<div class="fr-modal__content">
<h1
id="fr-modal-title-modal-1"
:id="modalId"
class="fr-modal__title"
>
<span
Expand Down
3 changes: 1 addition & 2 deletions src/components/DsfrTable/DsfrTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import DsfrTableHeaders from './DsfrTableHeaders.vue'
import { type DsfrTableHeadersProps } from './DsfrTableHeaders.vue'
const props = withDefaults(defineProps<{
title?: string
title: string
headers?: DsfrTableHeadersProps
rows?:(DsfrTableRowProps | string[])[]
noCaption?: boolean
pagination?: boolean
defaultCurrentPage?: number
defaultOptionSelected?: number
}>(), {
title: undefined,
headers: () => [],
rows: () => [],
defaultCurrentPage: 1,
Expand Down
4 changes: 2 additions & 2 deletions src/components/DsfrTable/DsfrTableHeader.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts" setup>
import { type ThHTMLAttributes } from 'vue'
import { type CustomizeIconType, OhVueIcon as VIcon } from 'oh-vue-icons'
import { OhVueIcon as VIcon } from 'oh-vue-icons'
export type DsfrTableHeaderProps = {
header?: string
headerAttrs?: ThHTMLAttributes & { onClick?: (e: MouseEvent) => void }
icon?: CustomizeIconType
icon?: InstanceType<typeof VIcon>['$props']
}
withDefaults(defineProps<DsfrTableHeaderProps>(), {
Expand Down
22 changes: 21 additions & 1 deletion src/components/DsfrTabs/DsfrTabs.stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from '@storybook/jest'
import { within, userEvent } from '@storybook/testing-library'
import DsfrButton from '../DsfrButton/DsfrButton.vue'
import DsfrTabs from './DsfrTabs.vue'
import DsfrTabContent from './DsfrTabContent.vue'

Expand Down Expand Up @@ -130,7 +131,7 @@ const customTabTitles = [
]

export const OngletsComplexes = (args) => ({
components: { DsfrTabs, DsfrTabContent },
components: { DsfrTabs, DsfrTabContent, DsfrButton },
data () {
return {
...args,
Expand All @@ -140,6 +141,7 @@ export const OngletsComplexes = (args) => ({

template: `
<DsfrTabs
ref="tabs"
:tab-list-name="tabListName"
:tab-titles="tabTitles"
:initial-selected-index="initialSelectedIndex"
Expand Down Expand Up @@ -181,6 +183,24 @@ export const OngletsComplexes = (args) => ({
<div>Contenu 4 avec d'autres composants</div>
</DsfrTabContent>
</DsfrTabs>
<div style="display: flex; gap: 1rem; margin-block: 1rem;">
<DsfrButton
label="Activer le 1er onglet"
@click="() => { $refs.tabs.selectFirst() }"
/>
<DsfrButton
label="Activer le 2è onglet"
@click="() => { $refs.tabs.selectIndex(1) }"
/>
<DsfrButton
label="Activer le 3è onglet"
@click="() => { $refs.tabs.selectIndex(2) }"
/>
<DsfrButton
label="Activer le dernier onglet"
@click="() => { $refs.tabs.selectLast() }"
/>
</div>
`,

methods: {
Expand Down
6 changes: 6 additions & 0 deletions src/components/DsfrTabs/DsfrTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ const selectFirst = async () => {
const selectLast = async () => {
await selectIndex(props.tabTitles.length - 1)
}
defineExpose({
selectIndex,
selectFirst,
selectLast,
})
</script>

<template>
Expand Down

0 comments on commit 660e4d5

Please sign in to comment.