Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: theming enhancements and additions #459

Merged
merged 27 commits into from
Jun 12, 2024

Conversation

stephiescastle
Copy link
Member

@stephiescastle stephiescastle commented Jun 11, 2024

Checklist

  • Include a description of your pull request and instructions for the reviewer to verify your work.
  • Link to the issue if this PR is issue-specific.
  • Create/update the corresponding story if this includes a UI component.
  • Create/update documentation. If not included, tell us why.
  • List the environments / browsers in which you tested your changes.
  • Tests, linting, or other required checks are passing.
  • PR has an informative and human-readable title
    • PR titles are used to generate the change log in releases; good ones make that easier to scan.
    • PRs will be broadly categorized in the change log, but for even easier scanning, consider prefixing with a component name or other useful categorization, e.g., "BaseButton: fix layout bug", or "Storybook: Update dependencies".
  • PR has been tagged with a SemVer label and a general category label, or skip-changelog.
    • These tags are used to do the aforementioned broad categorization in the change log and determine what the next release's version number should be.
    • Release Drafter will attempt to do the category labeling for you! Please double-check its work.

Description

Fixes https://github.com/nasa-jpl/www/issues/50
Fixes https://github.com/nasa-jpl/www/issues/53
Starts https://github.com/nasa-jpl/www/issues/48
Starts https://github.com/nasa-jpl/www/issues/21

  • modifies structure of color definitions
  • updates color definitions
  • updates heading type styles for EDU theme
  • adds star background as a themed Tailwind class (usage for EDU: class="bg-star bg-primary").
  • adds tailwindcss-themer
  • moves theme settings to the nuxt module (no longer need to manually add theme classes)
  • adds a theme store that can be used as a vue directive (can check which theme is in use and use that in Vue logic). The nuxt module automatically installs this store and sets the theme accordingly.
  • fixes all unsplash images in storybook
  • adds theming to existing components. this does not include new components needed by EDU, or any of the "pill" style badges added to cards.
  • adds PageEventDetail component
  • updated Foundations documentation to include themes and dynamic color tokens, and added to @explorer-1/vue-storybook
  • adds story for MixinCarousel

Using the themes

Themes can be:

  • Used as Tailwind modifiers/directives
  • Retrieved from the pinia store to use in Vue logic
  • Used as a class at the block level, with some caveats

Tailwind modifiers and directives

The theme can be used as an inline Tailwind modifier

  • defaultTheme:
  • edu:
  • internal:
<div class="bg-jpl-blue-dark edu:bg-primary">

They also work with the @apply directive:

.custom_class {
  @apply font-medium edu:font-extrabold
}

In Vue logic

Options API

<script>
import { mapStores } from 'pinia'
import { useThemeStore } from '../../store/theme'

export default defineComponent({
  computed: {
    ...mapStores(useThemeStore),
    buttonVariant() {
      return this.themeStore.theme === 'ThemeEdu' ? 'reverse-primary' : 'primary'
    }
  }
})
</script>

Composition API

<script setup>
import { useThemeStore } from '../../store/theme'

const themeStore = useThemeStore()

const buttonVariant = computed(() => {
  return this.themeStore.theme === 'ThemeEdu' ? 'reverse-primary' : 'primary'
})
</script>

Used as a class

.defaultTheme
.ThemeEdu
.ThemeInteral

These classes are generally applied to the <html> element, but they can also be used at the block level. However, if you plan to do this, you will need to provide fallbacks for all theme variations within the block.

For example: the code from above would need to be changed to work as expected in the below example:

<html class="ThemeEdu">
  ...
  <div class="ThemeInternal>
-   <div class="bg-jpl-blue-dark edu:bg-primary">
+   <div class="bg-jpl-blue-dark edu:bg-primary internal:bg-jpl-blue-dark">

Note that using theme classes directly only affects CSS -- They will not be taken into account with useThemeStore().

Implementation Notes

  • At this point, the documentation in @explorer-1/html-storybook will be deprecated (this is the storybook that is published to our gh pages), as it won't accurately show all of the theming differences. This was the motivation behind moving foundational documentation to @explorer-1/vue-storybook.
  • In a follow-up task, I will be adding CI checks that will make @explorer-1/vue-storybook available: https://github.com/nasa-jpl/www/issues/81
  • The star background sizing isn't quite right. I'll continue to tweak this.

Instructions to test

  1. pnpm i
  2. make vue-storybook
  3. New colors added: http://localhost:6006/?path=/docs/foundation-colors--docs
  4. Try switching between themes on the following:

You can also test this with the EDU frontend:

  1. Checkout https://github.com/nasa-jpl/www/pull/74
  2. make checkout-submodules
  3. pnpm i
  4. make frontend
  5. View at http://localhost:3000
  6. make edu
  7. View at http://localhost:3001/edu/

Tested in the following environments/browsers:

Operating System

  • macOS
  • iOS
  • iPadOS
  • Windows

Browser

  • Chrome
  • Firefox ESR
  • Firefox
  • Safari
  • Edge

@stephiescastle stephiescastle marked this pull request as draft June 11, 2024 00:16
@stephiescastle stephiescastle added storybook This issue relates to Storybook.js minor Contains new features or enhancements feature parity Work needed to maintain consistency between our implementations of Explorer 1 labels Jun 12, 2024
@stephiescastle stephiescastle changed the title Feature/additional theming Feature: theming enhancements and additions Jun 12, 2024
@stephiescastle stephiescastle marked this pull request as ready for review June 12, 2024 05:01
@stephiescastle stephiescastle requested a review from jamesray June 12, 2024 05:01
@jamesray
Copy link
Member

Great work @stephiescastle !

@stephiescastle stephiescastle merged commit bef830e into main Jun 12, 2024
1 check passed
@stephiescastle stephiescastle deleted the feature/additional-theming branch June 12, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature parity Work needed to maintain consistency between our implementations of Explorer 1 feature minor Contains new features or enhancements storybook This issue relates to Storybook.js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants