# Frontend Shared This package contains components and other code (such as WindiCSS config) that is shared between the `app` (Cypress web app) and `launchpad` (Cypress Electron app) packages. Any functionality that is intended to be the same in both can be added here and imported in those packages as needed. Base components like form inputs, cards, and modals, are written here, as well as higher-level components that exist in both apps, like the header. Conceivably, other packages may be created that also import from this shared component package. ## Building ### For development In this package, we use Cypress Component Tests to develop the components in isolation, and no E2E tests. E2E tests should be written in the packages that consume these components (`app` and `launchpad`). This means that there is no app to visit for development, instead, we open Cypress: ```bash ## from repo root yarn workspace @packages/frontend-shared cypress:open ``` ## Developing For the best development experience, you will want to use VS Code with the [Volar](https://marketplace.visualstudio.com/items?itemName=vue.volar) extension. This will give you type completion inside `vue` files. ## Testing ```bash ## from repo root yarn workspace @packages/frontend-shared cypress:run:ct ``` ## Utility class usage WindiCSS can create an awesome interactive summary showing our usage of utility classes and design tokens. Running this command will generate this report and serve it on localhost. ```bash ## from this directory yarn windi ``` This will be useful from time to time so that we can audit our usage of these classes and extract repeated patterns into Windi shortcuts or otherwise consolidate them, when it makes sense to do so. ## Link Components There are two shared components involved with links - `BaseLink`, and `ExternalLink`. `BaseLink` is responsible for default colors and hover/focus styles. `ExternalLink` wraps `BaseLink` is responsible for managing the GraphQL mutation that triggers links to open the in the user's default browser. ## Generate the theme for shiki See [the readme in the src/public/shiki/themes directory](./src/public/shiki/themes/ReadMe.md) ## Front-end Conventions, Underlying Ideas, and Gotchas These apply to this package, `app`, and `launchpad`, as well as any future work in this Vue-Tailwind-GQL stack. The goal is for this to provide useful context for new developers adding features to the codebase, or making changes to existing features. There are pros and cons to all of these decisions, but rather than get into those in detail, this is just a document of what practices we are following. ### Development Workflow We recommend component-based test driven development. More details in the [Testing Practices](../../guides/testing-strategy-and-styleguide.md) guide. To make changes to an existing component: 1. Open Cypress and go to the spec that covers the component (often it's 1:1 but sometimes components are tested via their parents) 1. Update the test to reflect the desired change (or part of it) 1. Implement the change in the component 1. Add Percy snapshot for any new unique states covered by the change To create a new component: 1. Add a component spec file and the component file itself as siblings in the desired location 1. In the spec file, import and mount the component. If the component depends on a GQL fragment, use `mountFragment` to mount the component so it can receive test data through the `gql` prop. ### Vue 3 If you are new to Vue 3, there are some new features we are using in this codebase that you should become familiar with. But first, if you are coming from React to Vue 3, here's a small potential gotcha to note as you read and write Vue code: the idea of a `ref` in Vue is similar to a `ref` in React but with a major difference. In React, when a ref's value changes, it doesn't trigger an update, or get "noticed" at all, by default. In Vue, a ref is part of the reactivity system and when the value updates, the component knows this and the updated value is reflected wherever the value is referenced. This can mean DOM updates, watchers firing, etc. Here are some features of Vue 3, and packages in the ecosystem, that are worth knowing about as we work in the codebase. #### Composition API and `