Python task manager from scratch, part 34: Adding styles based on task states
Now that we have the rest of the infrastructure in place, adding classes is straightforward. A few notes about this change:
- A list of classes separated by whitespace is treated in CSS as applying each of the strings separately. So
class="widget-description special new" will cause three classes--
new--to be applied to the item.
- I have not tested or verified the styling of the
stale rules. Rather than build out the infrastructure for adding test data created in the past ad hoc, I'll wait until there's proper QA / test environment infrastructure in place. (Stay tuned!)
- It's valuable to do the class-determination logic in a function, even though it's fairly simple. It adds almost no complexity, it's readable, and it prevents this and future logic from getting spread out through the code. It's very easy for a future developer needing to change this logic to introduce bugs and nonobvious dependencies; having it contained in a function helps.
Here's the current commit in the