{/*
Client showcase component.
2-column grid cards with logo on top, links stacked below description.
Defaults to shuffled order for fairness; toggle to switch to alphabetical.
*/}
export const ClientShowcase = ({clients}) => {
const shuffle = (arr) => {
const copy = arr.slice();
for (let i = copy.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[copy[i], copy[j]] = [copy[j], copy[i]];
}
return copy;
};
const sort = (clients) => clients.toSorted((a, b) => a.name.localeCompare(b.name));
const [state, dispatch] = React.useReducer((state, action) => {
switch (action) {
case "shuffle": return { mode: "shuffle", clients: shuffle(clients) };
case "alpha": return { mode: "alpha", clients: sort(clients) };
default: return state;
}
}, { mode: "shuffle", clients: shuffle(clients) });
const Logo = ({ client }) => (
);
const ToggleButton = ({ active, onClick, icon, title }) => (
);
return (
{client.description}
{(client.instructionsUrl || client.sourceCodeUrl) && (