Skip to content

feat(react/homepage): #COCO-5441, school widget#468

Open
jcbe-ode wants to merge 9 commits intoepic-homepagefrom
feat/COCO-5441-school-widget
Open

feat(react/homepage): #COCO-5441, school widget#468
jcbe-ode wants to merge 9 commits intoepic-homepagefrom
feat/COCO-5441-school-widget

Conversation

@jcbe-ode
Copy link
Contributor

@jcbe-ode jcbe-ode commented Mar 23, 2026

Description

Adds a new “SchoolWidget” for the React homepage module (with styling, Storybook stories, and tests).
Adds a hook to help populating the widget properties.
Updates the client School session type to reflect nullable exports (as seen during local tests).

Changes:

  • Introduce SchoolWidget component + Storybook stories for single/multiple/empty states.
  • Add useUserSchools hook to derive schools/selected school from EdificeClientProvider.
  • Update School.exports typing in the client session interfaces (string[] | null) and add widget CSS/SVG background.

Ticket https://edifice-community.atlassian.net/browse/COCO-5441

Which Package changed?

Please check the name of the package you changed

  • Components
  • Core
  • Icons
  • Hooks

Has the documentation changed?

  • Storybook

Type of change

Please check options that are relevant.

  • Chore (PATCH)
  • Doc (PATCH)
  • Bug fix (PATCH)
  • New feature (MINOR)
  • Breaking change (MAJOR)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “SchoolWidget” for the React homepage module (with styling, Storybook stories, and a helper hook) and updates the client School session type to reflect nullable exports.

Changes:

  • Introduce SchoolWidget component + Storybook stories for single/multiple/empty states.
  • Add useUserSchools hook to derive schools/selected school from EdificeClientProvider.
  • Update School.exports typing in the client session interfaces (string[] | null) and add widget CSS/SVG background.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/react/src/modules/homepage/components/SchoolWidget/useUserSchools.ts New hook to read user schools and manage selected school state.
packages/react/src/modules/homepage/components/SchoolWidget/SchoolWidget.tsx New UI widget rendering selected school + dropdown when multiple schools.
packages/react/src/modules/homepage/components/SchoolWidget/SchoolWidget.stories.tsx Storybook coverage for multiple/single/empty scenarios.
packages/react/src/modules/homepage/components/SchoolWidget/SchoolWidget.css Widget styling + CSS variables + background image binding.
packages/react/src/modules/homepage/components/SchoolWidget/SchoolWidgetBackground.svg Background asset for the widget.
packages/client/src/ts/session/interfaces.ts Update School.exports to allow null from the API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@damienromito damienromito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Une décision à prendre sur l'endroit où mettre le style. Discussion à avoir avec @pascalsaussier-edifice

En terme de design j'attend confirmation de Simon https://www.figma.com/design/UbAKNC5vk5XOj62z6CI4Qm?node-id=2146-36161#1690237762
Mais ça sera probablement :

  • si le texte est plus grand que le container, ajouter un elipsis au lieu de passer sur deux le lignes
  • le background doit être sticky en haut du block et pas en bas

@@ -0,0 +1,15 @@
.school-widget {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dans le forntend framework le css n'est pas pris en compte si il est dans les composant (on s'en rendra compte uniquement lorsqu'on importera le ticket dans un projet).
Il faut donc créer un fichier .scss (exemple)
Cela permet aussi d'utiliser les variables sass mais surtout de gerer tout le style dans bootstrap

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bon attention, goût personnel, mais c'est un truc que j'aimerais bien retirer, le fait de ne pas avoir le css dans les composants ça m'emmerde, ça rend la lecture compliquée et la maintenance pas intuitive.
Mais c'est pas un chantier pour maintenant, on verra plus tard. Donc en attendant oui, on garde les guidelines de FF et direction le package bootstrap.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Par contre très bien les vars scopées sur le composant lui-même.


const hasManySchools = schools && schools.length > 1;

const widgetStyle = { padding: '1.4rem 0.4rem' };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mettre le css en dehors du composant et au même endroit, dans le fichier .scss (cf commentaire precedent). C'est un point important à acter pour le rester du projet

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tout ce style doit être dans un fichier CSS ou SCSS.
Les seuls styles inlines qu'on va s'autoriser sont ceux qui sont calculés en fonction d'un state ou d'une variable du composant.

const widgetStyle = { padding: '1.4rem 0.4rem' };
const containerStyle = { padding: '0.8rem' };
const selectedSchoolStyle = {
padding: '.4rem 2.9rem',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pour les espacement, dans les application on utiliser les classes bootstrap (p-8, p12,...), dans le FF il faut utiliser les spacer (qui ne peut que être utilisé dans les fichiers sass dans bootstrap justement, exemple)

Ici il s'agit d'un spacer 1.2 (12pixel sur figma)

Image

color="tertiary"
variant="ghost"
icon={
<IconRafterDown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wahou chiant d'avoir dû reimplementer ça. J'ai fait un commentaire à simon https://www.figma.com/design/UbAKNC5vk5XOj62z6CI4Qm?node-id=2146-36161#1690319223

Comment on lines +95 to +104
export const Empty: Story = {
render: renderWithProps({ selectedSchool: undefined }),
parameters: {
docs: {
description: {
story: `État vide (aucune école)`,
},
},
},
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est vraiment utile ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'aime bien avoir la possibilité de voir les Edge Case dans storybook, ça retire pas mal de questionnements quand on regarde le composant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est ce que le cas avec aucune ecole est possible ?

@@ -0,0 +1,122 @@
// packages/react/src/modules/homepage/components/SchoolWidget/useUserSchools.test.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme pour le style, je pense qu'a la compilation , l'image ne sera pas ajoutée aux assets (tester en utilisant le composant dans Actualites par exemple).
Je vois qu'il y a un dossier react/modules/icons , sinon ajouter dans le dossier /bootstrap.
Quelle est la bonne pratique @pascalsaussier-edifice ?

setSelectedSchool(
index < 0 || index >= schools.length ? schools[0] : schools[index],
);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est ce vraiment utile de gerer ce cas ? c'est possible fonctionnellement qu'il passe à undefined ?

border-radius: 2.4rem;

background-color: var(--school-widget-bg-color);
background-image: url('./SchoolWidgetBackground.svg');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est une image qui va être lié aux préférénces de couleur qui seront accessibles dans le panneau de configuration. Pas en v1 mais faudra y penser.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. bien vu, mais c'est un comportement qu'on va devoir mettre en place à plusieurs endroit. Tu as une idée de comment faire ? on peut passer des proriétés à un svg ?

Comment on lines +95 to +104
export const Empty: Story = {
render: renderWithProps({ selectedSchool: undefined }),
parameters: {
docs: {
description: {
story: `État vide (aucune école)`,
},
},
},
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'aime bien avoir la possibilité de voir les Edge Case dans storybook, ça retire pas mal de questionnements quand on regarde le composant

@@ -0,0 +1,15 @@
.school-widget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bon attention, goût personnel, mais c'est un truc que j'aimerais bien retirer, le fait de ne pas avoir le css dans les composants ça m'emmerde, ça rend la lecture compliquée et la maintenance pas intuitive.
Mais c'est pas un chantier pour maintenant, on verra plus tard. Donc en attendant oui, on garde les guidelines de FF et direction le package bootstrap.

@@ -0,0 +1,15 @@
.school-widget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Par contre très bien les vars scopées sur le composant lui-même.


const hasManySchools = schools && schools.length > 1;

const widgetStyle = { padding: '1.4rem 0.4rem' };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tout ce style doit être dans un fichier CSS ou SCSS.
Les seuls styles inlines qu'on va s'autoriser sont ceux qui sont calculés en fonction d'un state ou d'une variable du composant.

style={{
transition: 'rotate 0.2s ease-out',
rotate: isExpanded ? '0deg' : '-180deg',
}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si tu peux mettre un TODO pour récupérer ce que j'ai fait sur le composant de Partage

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cad ? Tu peux mettre un lien sur le code en question

cdnDomain?: string | null;
version?: string | null;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci pour le nettoyage !

globals: true,
environment: 'jsdom',
include: ['src/**/*.spec.tsx'],
include: ['src/**/*.spec.tsx', 'src/**/*.spec.ts'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question pour plus tard, sur les sites on utilise plutôt .test.ts[x] le .spec.ts[x] c'est surtout un héritage d'Angular, est-ce que ça vaudrait pas le coup de normaliser avec le .test ?
@damienromito

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi pas, test est plus explicite en effet, mais il faudra le changer partout ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants