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

EcrituresNumeriques / stylo / 12925854411

23 Jan 2025 09:11AM UTC coverage: 25.831% (-4.7%) from 30.523%
12925854411

push

github

web-flow
Merge pull request #1192 from EcrituresNumeriques/feat/vite6

322 of 518 branches covered (62.16%)

Branch coverage included in aggregate %.

3448 of 14077 relevant lines covered (24.49%)

1.66 hits per line

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

0.0
/front/src/components/Write/ReferenceList.jsx
1
import React, { useCallback, useState } from 'react'
×
2
import { shallowEqual, useSelector } from 'react-redux'
×
3
import { Search } from 'react-feather'
×
4
import { useTranslation } from 'react-i18next'
×
5

6
import Reference from './Reference'
×
7
import styles from './ReferenceList.module.scss'
×
8
import Field from '../Field'
×
9
import Button from '../Button'
×
10

11
export default function ReferenceList() {
×
12
  const bibliographyEntries = useSelector(
×
13
    (state) => state.workingArticle.bibliography.entries,
×
14
    shallowEqual
×
15
  )
×
16
  const [filter, setFilter] = useState('')
×
17
  const [showAll, setShowAll] = useState(false)
×
18
  let bibTeXFound
×
19
  if (filter) {
×
20
    bibTeXFound = bibliographyEntries.filter(
×
21
      (entry) => entry.key.toLowerCase().indexOf(filter.toLowerCase()) > -1
×
22
    )
×
23
  } else {
×
24
    if (showAll) {
×
25
      bibTeXFound = bibliographyEntries
×
26
    } else {
×
27
      bibTeXFound = bibliographyEntries.slice(0, 25)
×
28
    }
×
29
  }
×
30
  const handleShowAll = useCallback(() => setShowAll(true), [])
×
31
  const { t } = useTranslation()
×
32
  return (
×
33
    <>
×
34
      <Field
×
35
        className={styles.searchField}
×
36
        type="text"
×
37
        icon={Search}
×
38
        value={filter}
×
39
        placeholder={t('write.searchFieldBiblio.placeholder')}
×
40
        onChange={(e) => setFilter(e.target.value)}
×
41
      />
×
42
      {filter && (
×
43
        <span className={styles.resultFoundCount}>
×
44
          {bibTeXFound.length} found
×
45
        </span>
×
46
      )}
47
      {bibTeXFound.map((entry, index) => (
×
48
        <Reference key={`ref-${entry.key}-${index}`} entry={entry} />
×
49
      ))}
×
50
      {!showAll && bibliographyEntries.length > 25 && (
×
51
        <Button className={styles.showAll} onClick={handleShowAll}>
×
52
          {t('write.showBiblio.button')} {bibliographyEntries.length} references
×
53
        </Button>
×
54
      )}
55
    </>
×
56
  )
57
}
×
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