Compare commits

..

11 Commits

Author SHA1 Message Date
Nonimart
0b1bdf39c3 STYLE Finetuning notyf toast style for cite button
All checks were successful
continuous-integration/drone/push Build is passing
2025-06-20 15:19:32 +02:00
Nonimart
48379f8c5a FEATURE Introducing the cite reference component 2025-06-20 15:19:08 +02:00
Nonimart
67fc1a69d3 FEATURE Introducing the cite reference component 2025-06-20 15:19:02 +02:00
Nonimart
ad49b2004c REFACTOR Renaming quote button to cite button 2025-06-20 15:02:07 +02:00
Nonimart
6efb8a29c5 REFACTOR Switching from JS files to TS files 2025-06-20 15:01:41 +02:00
Nonimart
7a59f3c880 STYLE Hiding ref-blibliographique 2025-06-20 15:01:23 +02:00
Nonimart
a4e4f41767 STYLE Updating social buttons aspect 2025-06-20 15:01:05 +02:00
Nonimart
19a3a0d313 FEATURE developping footnote-references styles 2025-06-20 15:00:48 +02:00
Nonimart
d99d3e5c9d IMPORT introducing footnote-references styles 2025-06-20 15:00:35 +02:00
Nonimart
244c0d8642 REFACTOR Temp comment on typography style because inherited form parent theme 2025-06-20 14:59:43 +02:00
Nonimart
e8d79eb91c CHORE Updating can I use 2025-06-20 14:59:22 +02:00
13 changed files with 177 additions and 72 deletions

19
package-lock.json generated
View File

@ -510,9 +510,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001359",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001359.tgz",
"integrity": "sha512-Xln/BAsPzEuiVLgJ2/45IaqD9jShtk3Y33anKb4+yLwQzws3+v6odKfpgES/cDEaZMLzSChpIGdbOYtH9MyuHw==",
"version": "1.0.30001724",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001724.tgz",
"integrity": "sha512-WqJo7p0TbHDOythNTqYujmaJTvtYRZrjpP8TCvH6Vb9CYJerJNKamKzIWOM4BkQatWj9H2lYulpdAQNBe7QhNA==",
"dev": true,
"funding": [
{
@ -522,8 +522,13 @@
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
]
],
"license": "CC-BY-4.0"
},
"node_modules/chalk": {
"version": "4.1.2",
@ -3647,9 +3652,9 @@
"dev": true
},
"caniuse-lite": {
"version": "1.0.30001359",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001359.tgz",
"integrity": "sha512-Xln/BAsPzEuiVLgJ2/45IaqD9jShtk3Y33anKb4+yLwQzws3+v6odKfpgES/cDEaZMLzSChpIGdbOYtH9MyuHw==",
"version": "1.0.30001724",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001724.tgz",
"integrity": "sha512-WqJo7p0TbHDOythNTqYujmaJTvtYRZrjpP8TCvH6Vb9CYJerJNKamKzIWOM4BkQatWj9H2lYulpdAQNBe7QhNA==",
"dev": true
},
"chalk": {

View File

@ -14,6 +14,7 @@
@import './components/post-card-dbmod.css';
@import './components/news-card.css';
@import './components/post-grid.css';
@import './components/footnote-reference.css';
@import './components/revues-grid.css';
@import './components/articles-grid.css';

View File

@ -1,6 +1,6 @@
@import url('https://fonts.googleapis.com/css2?family=Fjalla+One&family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap');
/* @import url('https://fonts.googleapis.com/css2?family=Fjalla+One&family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap'); */
body {
/* body {
font-family: 'Nunito Sans', sans-serif;
@apply text-primary text-xl;
}
@ -36,7 +36,7 @@ body.wp-admin h6:not(.editor-visual-editor h6) {
letter-spacing: unset !important;
text-transform: unset !important;
text-align: unset !important;
}
} */
.nunito {
font-family: 'Nunito Sans', sans-serif;

View File

@ -0,0 +1,12 @@
.footnote-reference {
color: unset;
&:after {
@apply nunito;
}
.wp-block-pullquote & {
&:after {
transform: translate(0px, -6px);
}
}
}

View File

@ -36,8 +36,17 @@
.socials-buttons {
@apply flex gap-4;
&__button {
@apply bg-white text-carhop-green-700 px-4 py-2 font-normal w-32 rounded-full border-primary w-fit border-2 flex items-center gap-2;
@apply bg-white text-carhop-green-700 px-4 py-2 font-normal rounded-full border-primary w-fit border-2 flex items-center gap-2;
transition: transform 0.3s ease-in-out;
&:hover {
transform: scale(1.05);
}
&[disabled='true'] {
@apply opacity-50 cursor-not-allowed;
}
img {
@apply w-8 h-8 filter-primary;
}

View File

@ -63,11 +63,17 @@
p {
@apply mb-6;
}
h1 {
@apply mb-10;
}
h2,
h3 {
@apply font-bold nunito mb-3 mt-12;
font-size: 1.7rem;
}
}
#cite-reference {
@apply hidden;
}
}

View File

@ -1,6 +1,8 @@
import menuInit from './header';
import singleRevue from './single-revue';
import singlesInit from './singles';
window.addEventListener('DOMContentLoaded', function () {
menuInit();
singleRevue();
singlesInit();
});

View File

@ -1,58 +0,0 @@
export default function singleRevue() {
const isSingleRevue = document.querySelector(
'.page--single-revue'
);
if (!isSingleRevue) return;
handleButtons();
hydrateRevueAuthors();
handleAuthorsButton();
}
function getRevueID() {
const revueID = document
.querySelector('.page--single-revue')
.getAttribute('data-revue-id');
return revueID ?? null;
}
function handleAuthorsButton() {
const authorsButton = document.querySelector(
'.authors-button'
);
authorsButton.addEventListener('click', () => {
hydrateRevueAuthors();
});
}
function handleButtons() {
const socialsButtons = document.querySelectorAll(
'.socials-buttons__button'
);
const shareButton = document.querySelector(
'.socials-buttons__button--share'
);
shareButton.addEventListener('click', () => {
// const url = window.location.href;
// const title = document.title;
// const text = 'Check out this article: ' + url;
// const shareUrl =
// 'https://www.facebook.com/sharer/sharer.php?u=' +
// encodeURIComponent(url);
// window.open(shareUrl, '_blank');
});
}
async function hydrateRevueAuthors() {
const revueID = getRevueID();
if (!revueID) return;
const response = await fetch(
`/wp-json/dynamiques-datas/v1/build/revue/authors?revue-id=${revueID}`
);
const revueAuthors = await response.json();
// console.log(revueAuthors);
const authorsList =
document.querySelector('.authors-list');
authorsList.innerHTML = revueAuthors.html_template;
}

View File

@ -0,0 +1,59 @@
interface RevueAuthorsResponse {
html_template: string;
}
export default function singleRevue(): void {
const isSingleRevue: HTMLElement | null =
document.querySelector('.page--single-revue');
if (!isSingleRevue) return;
hydrateRevueAuthors();
handleAuthorsButton();
}
function getRevueID(): string | null {
const revueElement: HTMLElement | null =
document.querySelector('.page--single-revue');
if (!revueElement) {
return null;
}
return revueElement.getAttribute('data-revue-id');
}
function handleAuthorsButton(): void {
const authorsButton: HTMLButtonElement | null =
document.querySelector('.authors-button');
if (authorsButton) {
authorsButton.addEventListener('click', () => {
hydrateRevueAuthors();
});
}
}
async function hydrateRevueAuthors(): Promise<void> {
const revueID = getRevueID();
if (!revueID) return;
try {
const response = await fetch(
`/wp-json/dynamiques-datas/v1/build/revue/authors?revue-id=${revueID}`
);
if (!response.ok) {
throw new Error(
`HTTP error! status: ${response.status}`
);
}
const revueAuthors: RevueAuthorsResponse =
await response.json();
const authorsList: HTMLElement | null =
document.querySelector('.authors-list');
if (authorsList) {
authorsList.innerHTML = revueAuthors.html_template;
}
} catch (error) {
console.error(
'Failed to fetch and hydrate revue authors:',
error
);
}
}

63
resources/js/singles.ts Normal file
View File

@ -0,0 +1,63 @@
export default function singles(): void {
const isSingleRevue: HTMLElement | null =
document.querySelector('.page--single-revue');
const isSingleArticle: HTMLElement | null =
document.querySelector('.page--single-articles');
if (!isSingleRevue && !isSingleArticle) return;
handleCiteButton();
}
function handleCiteButton(): void {
const citeButton: HTMLElement | null =
document.querySelector(
'.socials-buttons__button--cite'
);
const citeReference: HTMLElement | null =
document.querySelector('#cite-reference');
if (!citeButton || !citeReference) return;
if (!window.isSecureContext) {
citeButton.setAttribute('disabled', 'true');
citeButton.setAttribute(
'title',
'Vous devez utiliser un navigation sécurisé (https) pour copier la citation'
);
}
citeButton.addEventListener('click', () => {
const textToCopy = citeReference.textContent;
if (!textToCopy) return;
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard
.writeText(textToCopy)
.then(() => {
const notyf = new Notyf({
duration: 4000,
ripple: false,
dismissible: true,
types: [
{
type: 'success',
icon: {
className: 'notyf__icon--success',
tagName: 'i',
},
},
],
position: {
x: 'right',
y: 'top',
},
});
notyf.success(
'Citation copiée dans le presse-papiers ! <br> Vous pouvez maintenant la coller dans votre document.'
);
})
.catch((err) => {
console.error('Failed to copy text: ', err);
});
}
});
}

View File

@ -2,9 +2,15 @@
$articleID = $args['ID'];
$articleContent = get_the_content($articleID);
$articleTitle = get_the_title($articleID);
$citeReference = get_field('cite_reference', $articleID);
?>
<article class="article-content">
<h1><?php echo $articleTitle; ?></h1>
<?php echo $articleContent; ?>
<?php if ($citeReference) : ?>
<p id="cite-reference">
<?php echo $citeReference; ?>
</p>
<?php endif; ?>
</article>

View File

@ -62,7 +62,7 @@ $hasThumbnail = has_post_thumbnail();
</div>
<?php endif; ?>
<div class="socials-buttons">
<button class="socials-buttons__button socials-buttons__button--quote">
<button class="socials-buttons__button socials-buttons__button--cite">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-citer-article.svg" alt="">
Citer
</button>