components#CompareApiLink TypeScript Examples

The following examples show how to use components#CompareApiLink. 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: Category.tsx    From substrate-api-explorer with Apache License 2.0 6 votes vote down vote up
Category = ({ api, apiDiff, match }: Props) => {
  const { category } = match.params

  return (
    <S.Wrapper>
      <S.Title>
        <S.CategoryName>{category}</S.CategoryName>
        <CompareApiBreadcrumbs apiName={api.compare.url} match={match} />
      </S.Title>
      {_isEmpty(api.compare.description[category]) ? (
        <S.Empty>There&apos;s nothing in here ?</S.Empty>
      ) : (
        Object.entries(api.compare.description[category].categories)
          .sort((a: [string, Method], b: [string, Method]) => {
            return a[0] < b[0] ? -1 : 1
          })
          .map((item: [string, Method], idx) => {
            const added = !!apiDiff.added[category]?.categories[item[0]]
            const deleted = !!apiDiff.deleted[category]?.categories[item[0]]
            const updated = !!apiDiff.updated[category]?.categories[item[0]]
            const isNew =
              added && !api.current.description[category]?.categories[item[0]]

            return (
              (added || deleted || updated) && (
                <CompareApiLink
                  key={`compareApi-subcategory-${idx}`}
                  to={`${match.url}/${item[0]}`}
                  name={item[0]}
                  description={item[1].description}
                  states={{ added, deleted, updated, isNew }}
                />
              )
            )
          })
      )}
    </S.Wrapper>
  )
}
Example #2
Source File: Main.tsx    From substrate-api-explorer with Apache License 2.0 6 votes vote down vote up
Main = ({ api, apiDiff, match }: Props) => (
  <S.Wrapper>
    {_isEmpty(api.compare.description) ? (
      <S.Empty>There&apos;s nothing in here ?</S.Empty>
    ) : (
      Object.keys(api.compare.description)
        .sort()
        .map((item, idx) => {
          const added = !!apiDiff.added[item]
          const deleted = !!apiDiff.deleted[item]
          const updated = !!apiDiff.updated[item]
          const isNew = added && !api.current.description[item]

          return (
            (added || deleted || updated) && (
              <CompareApiLink
                key={`compareApi-category-${idx}`}
                to={`${match.url}/${item}`}
                name={item}
                description={api.compare.description[item].description}
                states={{ added, deleted, updated, isNew }}
              />
            )
          )
        })
    )}
  </S.Wrapper>
)
Example #3
Source File: CompareApiLink.stories.tsx    From substrate-api-explorer with Apache License 2.0 6 votes vote down vote up
storiesOf('COMPONENTS|CompareApiLink', module)
  .addDecorator(story => (
    <MemoryRouter initialEntries={['/']}>{story()}</MemoryRouter>
  ))
  .add('default', () => {
    const nameKnob = text('name', 'fooBar', 'props')
    const descriptionKnob = text(
      'description',
      'This is the description',
      'props'
    )
    const addedKnob = boolean('states.added', true, 'props')
    const deletedKnob = boolean('states.deleted', true, 'props')
    const updatedKnob = boolean('states.updated', true, 'props')

    return (
      <div style={{ maxWidth: 800, padding: '24px' }}>
        <CompareApiLink
          name={nameKnob}
          description={descriptionKnob}
          states={{
            added: addedKnob,
            deleted: deletedKnob,
            updated: updatedKnob
          }}
        />
      </div>
    )
  })