@@ -5,9 +5,10 @@ import {
55 Unstyled ,
66} from '@storybook/blocks'
77import { consoleLightTheme as lightTheme } from '@ultraviolet/themes'
8- import { ReactNode , cloneElement , isValidElement } from 'react'
8+ import { ReactNode , cloneElement , isValidElement , useState } from 'react'
99import { globalStyles } from './globalStyle'
1010import '@ultraviolet/fonts/fonts.css'
11+ import { GlobalAlert } from '@ultraviolet/ui'
1112
1213type ExtraProps = {
1314 /**
@@ -34,20 +35,44 @@ type ExtraProps = {
3435
3536type DocsContainerProps = BaseContainerProps & {
3637 context ?: {
37- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
38+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3839 attachedCSFFiles : Set < any >
3940 }
4041} & { children : ReactNode }
4142
4243const DocsContainer = ( { children, context } : DocsContainerProps ) => {
44+ const [ isBeta , setIsBeta ] = useState ( false )
4345 const scope = context ?. attachedCSFFiles ?. values ( ) ?. next ( ) ?. value ?. meta
4446 const parameters = scope ?. parameters
4547
4648 const isPlusLibrary = scope ?. title ?. includes ( 'Plus/' ) ?? false
4749
50+ if (
51+ import . meta. env [ 'STORYBOOK_ENVIRONMENT' ] === 'production' &&
52+ ! window . location . hostname . includes ( 'beta.storybook.ultraviolet.scaleway.com' )
53+ ) {
54+ fetch ( 'https://api.github.com/repos/scaleway/ultraviolet/branches/beta' )
55+ . then ( ( data ) => {
56+ if ( data . ok ) {
57+ setIsBeta ( true )
58+ }
59+ } )
60+ . catch ( ( ) => {
61+ setIsBeta ( false )
62+ } )
63+ }
64+
4865 return (
4966 < Unstyled >
5067 < ThemeProvider theme = { lightTheme } >
68+ { isBeta ?
69+ < GlobalAlert
70+ buttonText = "Access to Beta"
71+ onClickButton = { ( ) => window . top ?. location . assign ( 'https://beta.storybook.ultraviolet.scaleway.com' ) }
72+ closable = { false }
73+ >
74+ A Beta version is available. Please use this version if your dependencies include the Beta release.
75+ </ GlobalAlert > : null }
5176 < Global styles = { [ globalStyles ] } />
5277 < BaseContainer context = { context } >
5378 { isValidElement < ExtraProps > ( children )
0 commit comments