• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

EcrituresNumeriques / stylo / 16445774109

22 Jul 2025 01:30PM UTC coverage: 39.363% (+0.3%) from 39.037%
16445774109

push

github

web-flow
feat: nouveau composant accessible Toggle (#1603)

Co-authored-by: Thomas Parisot <thom4parisot@users.noreply.github.com>

586 of 824 branches covered (71.12%)

Branch coverage included in aggregate %.

70 of 119 new or added lines in 7 files covered. (58.82%)

1 existing line in 1 file now uncovered.

5777 of 15341 relevant lines covered (37.66%)

2.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/front/src/components/collaborative/CollaborativeEditorArticleHeader.jsx
1
import React, { useEffect, useState } from 'react'
×
2
import { useTranslation } from 'react-i18next'
×
3
import { useSearchParams } from 'react-router'
×
4

5
import useFetchData from '../../hooks/graphql.js'
×
6

7
import CollaborativeEditorActiveVersion from './CollaborativeEditorActiveVersion.jsx'
×
8
import CollaborativeEditorWriters from './CollaborativeEditorWriters.jsx'
×
NEW
9
import Loading from '../molecules/Loading.jsx'
×
NEW
10
import Toggle from '../molecules/Toggle.jsx'
×
11

12
import { getArticleInfo } from '../Article.graphql'
×
13

14
import styles from './CollaborativeEditorArticleHeader.module.scss'
×
15

16
/**
17
 * @param props
18
 * @param {string} props.articleId
19
 * @param {string?} props.versionId
20
 * @returns {import('react').ReactElementElement}
21
 */
22
export default function CollaborativeEditorArticleHeader({
×
23
  articleId,
×
24
  versionId,
×
25
}) {
×
26
  const { t } = useTranslation()
×
27

28
  const [searchParams, setSearchParams] = useSearchParams()
×
29
  const [mode, setMode] = useState('edit')
×
30

31
  const { data, isLoading } = useFetchData(
×
32
    { query: getArticleInfo, variables: { articleId } },
×
33
    {
×
34
      revalidateIfStale: false,
×
35
      revalidateOnFocus: false,
×
36
      revalidateOnReconnect: false,
×
37
      fallbackData: {
×
38
        article: {},
×
39
      },
×
40
    }
×
41
  )
×
42

43
  useEffect(() => {
×
44
    if (mode === 'preview' && searchParams.get('mode') !== 'preview') {
×
45
      setSearchParams({ mode: 'preview' })
×
46
    } else if (searchParams.get('mode') === 'preview') {
×
47
      setSearchParams({})
×
48
    }
×
49
  }, [mode])
×
50

51
  if (isLoading) {
×
52
    return <Loading />
×
53
  }
×
54

55
  return (
×
56
    <header className={styles.header}>
×
57
      <h1 className={styles.title}>{data.article.title}</h1>
×
58

59
      <div className={styles.row}>
×
NEW
60
        <Toggle
×
NEW
61
          id="preview-mode"
×
NEW
62
          checked={mode === 'preview'}
×
NEW
63
          title={t('article.editor.preview')}
×
NEW
64
          onChange={(checked) => setMode(checked ? 'preview' : 'edit')}
×
65
        >
NEW
66
          {t('article.editor.preview')}
×
NEW
67
        </Toggle>
×
68

69
        <div className={styles.writers}>
×
70
          <CollaborativeEditorWriters />
×
71
        </div>
×
72
      </div>
×
73
      <CollaborativeEditorActiveVersion versionId={versionId} />
×
74
    </header>
×
75
  )
76
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc