@material-ui/icons#List TypeScript Examples

The following examples show how to use @material-ui/icons#List. 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: index.tsx    From anchor-web-app with Apache License 2.0 4 votes vote down vote up
function PollsBase({ className }: PollsProps) {
  const {
    target: { isNative },
  } = useDeploymentTarget();

  const navigate = useNavigate();

  const { contractAddress } = useAnchorWebapp();

  const [option, setOption] = useState<anchorToken.gov.PollStatus>(
    () => options[0].value,
  );

  const { polls, isLast, loadMore: loadMorePolls } = useGovPollsQuery(option);

  const { data: { ancBalance: govANCBalance } = {} } = useAncBalanceQuery(
    contractAddress.anchorToken.gov,
  );

  const { data: { govState, govConfig } = {} } = useGovStateQuery();

  const [view, setView] = useLocalStorage<'grid' | 'list'>(
    '__anchor_polls_view__',
    'grid',
  );

  const onPollClick = useCallback(
    (poll: anchorToken.gov.PollResponse) => {
      navigate(`/poll/${poll.id}`);
    },
    [navigate],
  );

  return (
    <section className={className}>
      <SubHeader breakPoints={900}>
        <div>
          <h2>
            <IconSpan>
              Polls{' '}
              <InfoTooltip>
                Staked ANC can be used to exercise voting power in polls that
                are currently in progress
              </InfoTooltip>
            </IconSpan>
          </h2>

          <button
            className="icon-button"
            disabled={view === 'grid'}
            onClick={() => setView('grid')}
          >
            <ViewModule />
          </button>

          <button
            className="icon-button"
            disabled={view === 'list'}
            onClick={() => setView('list')}
          >
            <List />
          </button>

          <div />

          <NativeSelect
            value={option}
            style={{ width: 150, height: 40, marginLeft: 10 }}
            onChange={({ target }: ChangeEvent<HTMLSelectElement>) =>
              setOption(target.value as anchorToken.gov.PollStatus)
            }
          >
            {options.map(({ label, value }) => (
              <option key={value} value={value}>
                {label}
              </option>
            ))}
          </NativeSelect>
        </div>

        <div className="buttons">
          <BorderButton
            component="a"
            href={links.forum}
            target="_blank"
            rel="noreferrer"
          >
            Join Forum
          </BorderButton>
          {isNative && (
            <ActionButton component={Link} to={`/poll/create`}>
              Create Poll
            </ActionButton>
          )}
        </div>
      </SubHeader>

      {view === 'grid' ? (
        <GridView
          isLast={isLast}
          polls={polls}
          onClick={onPollClick}
          onLoadMore={loadMorePolls}
          govANCBalance={govANCBalance}
          govState={govState}
          govConfig={govConfig}
        />
      ) : (
        <ListView
          isLast={isLast}
          polls={polls}
          onClick={onPollClick}
          onLoadMore={loadMorePolls}
          govANCBalance={govANCBalance}
          govState={govState}
          govConfig={govConfig}
        />
      )}
    </section>
  );
}