Skip to content
Snippets Groups Projects
  • Phoomparin Mano's avatar
    4c3df61d
    feat(sdk): generate sample react component with the embedding cli (#46538) · 4c3df61d
    Phoomparin Mano authored
    
    * add setup commands
    
    * fix settings definition
    
    * update environment variables for cli
    
    * handle instances not being ready
    
    * update error messages
    
    * add more specific loading messages
    
    * loading spinner state
    
    * improve error message
    
    * use a fixed demo setup token
    
    * remove extraneous spinner
    
    * update status checks
    
    * update container messages
    
    * update wait timing
    
    * create api keys
    
    * extract constants
    
    * remove manual steps
    
    * Add anonymous tracking + other things. will need to clean up
    
    * Modify SDK for better structure
    
    * remove line from print.ts
    
    * Update webpack.embedding-sdk-cli.config.js back to production
    
    * Add types and add quick note
    
    * Fix a typo
    
    * Add index file, simplify types, use an array
    
    * Add safer json parsing
    
    * use delay of 100ms between each setup call
    
    * Suggestions from review
    
    * ensure that cli works
    
    * Attempt to fix jest errors
    
    * Remove node-fetch from sdk code to hopefully get unit tests working again
    
    * add database connection
    
    * add connection details handling
    
    * refactor asking for database connection info
    
    * apply actual database id for syncing schema
    
    * fix failing database sync step
    
    * allow table selection
    
    * create model for each table
    
    * handle errors in model creation
    
    * fix incorrect model display name
    
    * create x-rays based on user data
    
    * consolidate instance setup message
    
    * workaround for inquirer eventemitter issue
    
    * add sample components
    
    * fix yarn.lock file
    
    * add sample components
    
    * set spinner to fail state when instance setup fails
    
    * use a transparent background by default
    
    * update cli welcome messages
    
    * add import notice
    
    * refactor imports
    
    * update snippet to add dashboard dropdown
    
    * cli add credential file to users .gitignore
    
    * add docs on quickstart
    
    * clear screen with console.clear
    
    * address code review feedback
    
    Co-authored-by: default avatarNicolò Pretto <info@npretto.com>
    
    * allow node 18 lts
    
    ---------
    
    Co-authored-by: default avatarOisin Coveney <oisin@metabase.com>
    Co-authored-by: default avatarNicolò Pretto <info@npretto.com>
    feat(sdk): generate sample react component with the embedding cli (#46538)
    Phoomparin Mano authored
    
    * add setup commands
    
    * fix settings definition
    
    * update environment variables for cli
    
    * handle instances not being ready
    
    * update error messages
    
    * add more specific loading messages
    
    * loading spinner state
    
    * improve error message
    
    * use a fixed demo setup token
    
    * remove extraneous spinner
    
    * update status checks
    
    * update container messages
    
    * update wait timing
    
    * create api keys
    
    * extract constants
    
    * remove manual steps
    
    * Add anonymous tracking + other things. will need to clean up
    
    * Modify SDK for better structure
    
    * remove line from print.ts
    
    * Update webpack.embedding-sdk-cli.config.js back to production
    
    * Add types and add quick note
    
    * Fix a typo
    
    * Add index file, simplify types, use an array
    
    * Add safer json parsing
    
    * use delay of 100ms between each setup call
    
    * Suggestions from review
    
    * ensure that cli works
    
    * Attempt to fix jest errors
    
    * Remove node-fetch from sdk code to hopefully get unit tests working again
    
    * add database connection
    
    * add connection details handling
    
    * refactor asking for database connection info
    
    * apply actual database id for syncing schema
    
    * fix failing database sync step
    
    * allow table selection
    
    * create model for each table
    
    * handle errors in model creation
    
    * fix incorrect model display name
    
    * create x-rays based on user data
    
    * consolidate instance setup message
    
    * workaround for inquirer eventemitter issue
    
    * add sample components
    
    * fix yarn.lock file
    
    * add sample components
    
    * set spinner to fail state when instance setup fails
    
    * use a transparent background by default
    
    * update cli welcome messages
    
    * add import notice
    
    * refactor imports
    
    * update snippet to add dashboard dropdown
    
    * cli add credential file to users .gitignore
    
    * add docs on quickstart
    
    * clear screen with console.clear
    
    * address code review feedback
    
    Co-authored-by: default avatarNicolò Pretto <info@npretto.com>
    
    * allow node 18 lts
    
    ---------
    
    Co-authored-by: default avatarOisin Coveney <oisin@metabase.com>
    Co-authored-by: default avatarNicolò Pretto <info@npretto.com>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
theme-switcher-snippet.ts 1.07 KiB
export const THEME_SWITCHER_SNIPPET = `
import { useContext } from 'react'

import { SampleThemeContext } from './metabase-provider'

export const ThemeSwitcher = () => {
  const { themeKey, setThemeKey } = useContext(SampleThemeContext)

  const ThemeIcon = ICONS[themeKey]

  return (
    <div
      className="theme-switcher"
      onClick={() => setThemeKey(themeKey === 'light' ? 'dark' : 'light')}
    >
      <ThemeIcon />
    </div>
  )
}

const ICONS = {
  light: () => (
    <svg viewBox="0 0 24 24">
      <path
        fill="none"
        stroke="currentColor"
        strokeLinecap="round"
        strokeLinejoin="round"
        strokeWidth="2"
        d="M8 12a4 4 0 1 0 8 0a4 4 0 1 0-8 0m-5 0h1m8-9v1m8 8h1m-9 8v1M5.6 5.6l.7.7m12.1-.7l-.7.7m0 11.4l.7.7m-12.1-.7l-.7.7"
      />
    </svg>
  ),
  dark: () => (
    <svg viewBox="0 0 24 24">
      <path
        fill="none"
        stroke="currentColor"
        strokeLinecap="round"
        strokeLinejoin="round"
        strokeWidth="2"
        d="M12 3h.393a7.5 7.5 0 0 0 7.92 12.446A9 9 0 1 1 12 2.992z"
      />
    </svg>
  )
}
`;