components#ExploreApiConst TypeScript Examples

The following examples show how to use components#ExploreApiConst. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExploreApiConst.stories.tsx    From substrate-api-explorer with Apache License 2.0 6 votes vote down vote up
storiesOf('COMPONENTS|ExploreApiConst', module).add('default', () => {
  const nameKnob = text('name', 'bar', 'props')
  const pathKnob = text('path', 'api.query.foo.bar', 'props')
  const typeKnob = text('type', 'number', 'props')
  const descriptionKnob = text(
    'description',
    'This is the description.',
    'props'
  )
  const valueKnob = text('value', '123', 'props')

  return (
    <div style={{ maxWidth: 800, padding: '24px' }}>
      <ExploreApiConst
        name={nameKnob}
        path={pathKnob}
        type={typeKnob}
        description={descriptionKnob}
        value={valueKnob}
      />
    </div>
  )
})
Example #2
Source File: Subcategory.tsx    From substrate-api-explorer with Apache License 2.0 5 votes vote down vote up
Subcategory = ({ api, match }: Props) => {
  const { category, subcategory } = match.params

  return (
    <S.Wrapper>
      <S.Title>
        <S.CategoryName>
          <div>
            <strong>{subcategory}</strong>
            <span>
              Available {category === 'consts' ? 'consts' : 'methods'}:
            </span>
          </div>
        </S.CategoryName>
        <ExploreApiBreadcrumbs match={match} />
      </S.Title>
      {/* We have to disable ESLint here because it doesn't
      play nicely with Prettier */}
      {/* eslint-disable indent */}
      {_isEmpty(api.description[category]?.categories[subcategory]?.methods) ? (
        <S.Empty>There&apos;s nothing in here ?</S.Empty>
      ) : (
        Object.entries(
          api.description[category]?.categories[subcategory]?.methods
        )
          .sort((a: [string, Method], b: [string, Method]) => {
            return a[0] < b[0] ? -1 : 1
          })
          .map((item: [string, Method], idx) =>
            category === 'consts' ? (
              <ExploreApiConst
                key={`exploreApi-const-${idx}`}
                name={item[0]}
                path={`api.consts.${subcategory}.${item[0]}`}
                type={item[1].type}
                description={item[1].description}
                value={JSON.stringify(
                  api.promise[category][subcategory][item[0]]
                )}
              />
            ) : (
              <ExploreApiLink
                key={`exploreApi-subcategory-${idx}`}
                to={`${match.url}/${item[0]}`}
                name={item[0]}
                params={item[1].params}
                description={item[1].description}
              />
            )
          )
      )}
      {/* eslint-enable indent */}
    </S.Wrapper>
  )
}