diff --git a/src/articles/ArticlePreview.js b/src/articles/ArticlePreview.js index 89921b653..271c4ca5c 100644 --- a/src/articles/ArticlePreview.js +++ b/src/articles/ArticlePreview.js @@ -6,7 +6,6 @@ import "react-toastify/dist/ReactToastify.css"; import { isMobile } from "../utils/misc/browserDetection"; import * as s from "./ArticlePreview.sc"; import { MetaStrip, MetaItem, MetaLink, MetaTag } from "../components/MetaStrip.sc"; -import { classColor } from "../utils/misc/classColor"; import RedirectionNotificationModal from "../components/redirect_notification/RedirectionNotificationModal"; import Feature from "../features/Feature"; import strings from "../i18n/definitions"; @@ -296,14 +295,9 @@ export default function ArticlePreview({ // Which class a text came from. Only for a student in more than one class: // with a single class it is the same answer on every row, and the tab itself // already says it. Computed here because both layouts below render a strip. - // The class's own colour, matching its chip in the filter bar above -- the - // pair is what lets you skim the list for one class instead of reading every - // label. Colour supplements the name, never replaces it. const classTags = showClassNames ? (article.from_classes || []).map((each) => ( - - {each.name} - + {each.name} )) : null; diff --git a/src/articles/ClassroomArticles.js b/src/articles/ClassroomArticles.js index 6713ba345..212827e6a 100644 --- a/src/articles/ClassroomArticles.js +++ b/src/articles/ClassroomArticles.js @@ -14,7 +14,6 @@ import ClassroomOtherLanguages, { otherLanguageOptions, } from "./ClassroomOtherLanguages"; import { ALL, buildClassFilters, filterTexts } from "../utils/misc/classFilters"; -import { classColorTint } from "../utils/misc/classColor"; import * as f from "../teacher/styledComponents/TextFilterBar.sc"; export default function ClassroomArticles() { @@ -110,23 +109,18 @@ export default function ClassroomArticles() {
{inMoreThanOneClass && ( - {classFilters.map((filter) => { - const tint = filter.id === ALL ? {} : classColorTint(filter.id); - return ( + {classFilters.map((filter) => ( setActiveClass(filter.id)} > {filter.name} {filter.count} - ); - })} + ))} )} diff --git a/src/teacher/styledComponents/TextFilterBar.sc.js b/src/teacher/styledComponents/TextFilterBar.sc.js index abe987411..47c975f41 100644 --- a/src/teacher/styledComponents/TextFilterBar.sc.js +++ b/src/teacher/styledComponents/TextFilterBar.sc.js @@ -25,23 +25,6 @@ export const Chip = styled(Tag).attrs({ className: "tiny" })` white-space: nowrap; border-style: ${({ $dashed }) => ($dashed ? "dashed" : "solid")}; - /* $hue/$wash give a class its own colour, so a chip and the tags on the rows - below it read as the same thing. Selected fills with the hue; unselected - is a wash of it, which is alpha over the ground and so works in both - themes. Chips without a hue (All, Not shared) keep the neutral look. */ - ${({ $hue, $wash, $on }) => - $hue && - ($on - ? `border-color: ${$hue}; background-color: ${$hue}; color: white;` - : `border-color: ${$hue}; background-color: ${$wash}; color: ${$hue};`)} - - &, - &.small { - ${({ $on }) => - $on - ? `border-color: ${darkBlue}; background-color: ${darkBlue}; color: white; font-weight: 600;` - : `color: var(--text-secondary); font-weight: 500;`} - } `; export const ChipCount = styled.span` diff --git a/src/utils/misc/classColor.js b/src/utils/misc/classColor.js deleted file mode 100644 index 6df124038..000000000 --- a/src/utils/misc/classColor.js +++ /dev/null @@ -1,45 +0,0 @@ -import { - tableau_1, tableau_3, tableau_5, tableau_6, -} from "../../components/colors"; - -// From the repo's categorical palette (matplotlib's tab10), the hues that stay -// legible as small text on both the cream and the dark ground. Dropped: grey -// (a class is never "the other one"), red (reads as an error), olive, pink and -// cyan (too pale at this size), orange (the app's own accent). -// -// Six classes is more than anyone here has; beyond that they repeat, which is -// honest -- the colour is a hint on top of the name, never the only signal. -const PALETTE = [ - tableau_1, // blue - tableau_3, // green - tableau_5, // purple - tableau_6, // brown - "#0f766e", // teal - "#9a3412", // burnt orange -]; - -/** - * A stable colour for a class. - * - * Keyed off the class's id rather than its position in a list, so a class keeps - * its colour when the list is filtered, sorted, or a class is added — a colour - * that reshuffles is worse than no colour, because you stop trusting it. - */ -export function classColor(cohortId) { - const key = String(cohortId); - let hash = 0; - for (let i = 0; i < key.length; i++) { - hash = (hash * 31 + key.charCodeAt(i)) % 1000003; - } - return PALETTE[hash % PALETTE.length]; -} - -/** - * The pair a tinted chip needs: the hue for text and border, and a wash of it - * for the fill. The wash is alpha over whatever is behind it, so one value - * works on both the light and the dark ground. - */ -export function classColorTint(cohortId) { - const hue = classColor(cohortId); - return { hue, wash: `color-mix(in srgb, ${hue} 14%, transparent)` }; -}