Add Colors to js #17

Closed
snedadah wants to merge 0 commits from main into shahanneda/js-colors
Owner

The global colors pr will have to be merged before this one.

After further investgation, the solutions that we planned on using (getComputedStyle(document.documentElement) .getPropertyValue(property);) did not end up working, because of some wierd issues with nextjs. However, luckly it seems we can still just use the css variables inside the js (I tried it out with Amy's bar graph demo and it seemed to work well).
Thus I created a typesafe helper, utils/Colors.ts , anytime you need a color, you can use this object, eg.

import { Colors } from "utils/Colors";
<Text fill={Colors.primaryBackground}> ... </Text>

And importantly the Colors is typesafe so you can get autocomplete once you do Colors. :) (Protip: press Cntrl + Space if you want autocomplete to pop up when it isnt coming)

The global colors pr will have to be merged before this one. After further investgation, the solutions that we planned on using (`getComputedStyle(document.documentElement) .getPropertyValue(property);`) did not end up working, because of some wierd issues with nextjs. However, luckly it seems we can still just use the css variables inside the js (I tried it out with Amy's bar graph demo and it seemed to work well). Thus I created a typesafe helper, utils/Colors.ts , anytime you need a color, you can use this object, eg. import { Colors } from "utils/Colors"; <Text fill={Colors.primaryBackground}> ... </Text> And importantly the Colors is typesafe so you can get autocomplete once you do Colors. :) (Protip: press Cntrl + Space if you want autocomplete to pop up when it isnt coming)
snedadah closed this pull request 2022-06-18 20:31:18 -04:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: www/cs-2022-class-profile#17
No description provided.