-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add bundle environments to Atlas (#70)
* feature: add `environment` to Atlas bundles This is based on the custom transform options provided by Expo, with a fallback to `client`. * refactor(webui): extract platforms from `Tag` into `BundleTag` and add `environment` * refactor(webui): replace `Tag` with `BundleTag` versions * refactor(webui): update fixture with Expo SDK 51 default template
- Loading branch information
Showing
12 changed files
with
163 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
webui/fixture/atlas-tabs-51-windows.jsonl → webui/fixture/expo-51-default-windows.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
webui/fixture/atlas-tabs-51.jsonl → webui/fixture/expo-51-default.jsonl
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { cva, type VariantProps } from 'class-variance-authority'; | ||
import { type ComponentProps } from 'react'; | ||
|
||
import { Tag } from '~/ui/Tag'; | ||
import type { AtlasBundle } from '~core/data/types'; | ||
|
||
const bundleTagVariants = cva('', { | ||
variants: { | ||
platform: { | ||
android: 'bg-palette-green3 text-palette-green11', | ||
ios: 'bg-palette-blue3 text-palette-blue11', | ||
web: 'bg-palette-orange3 text-palette-orange11', | ||
server: 'bg-palette-orange3 text-palette-orange11', | ||
unknown: '', | ||
}, | ||
environment: { | ||
client: '', | ||
node: 'bg-palette-orange3 text-palette-orange11', | ||
'react-server': 'bg-palette-green3 text-palette-green11', | ||
}, | ||
}, | ||
defaultVariants: { | ||
platform: 'unknown', // Default platform value, see MetroGraphSource | ||
environment: 'client', // Default environment value, see MetroGraphSource | ||
}, | ||
}); | ||
|
||
const platformChildren: Record<AtlasBundle['platform'], string> = { | ||
android: 'Android', | ||
ios: 'iOS', | ||
server: 'Server', | ||
web: 'Web', | ||
unknown: '???', | ||
}; | ||
|
||
const environmentChildren: Record<AtlasBundle['environment'], string> = { | ||
client: 'Client', | ||
node: 'SSR', | ||
'react-server': 'RSC', | ||
}; | ||
|
||
type BundelTagProps = Omit< | ||
ComponentProps<typeof Tag> & VariantProps<typeof bundleTagVariants>, | ||
'children' | ||
>; | ||
|
||
export function BundleTag({ className, platform, environment, ...props }: BundelTagProps) { | ||
return ( | ||
<Tag | ||
className={bundleTagVariants({ platform, environment, className })} | ||
variant="none" | ||
{...props} | ||
> | ||
{getBundelTagChildren({ platform, environment })} | ||
</Tag> | ||
); | ||
} | ||
|
||
function getBundelTagChildren(props: BundelTagProps) { | ||
const children: string[] = []; | ||
|
||
if (props.platform) { | ||
children.push(platformChildren[props.platform]); | ||
} | ||
|
||
// Only add the environment specifier if it's not bundled for the client | ||
if (props.environment && props.environment !== 'client') { | ||
children.push(environmentChildren[props.environment]); | ||
} | ||
|
||
return children.join(' × '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters