components APIs
- Header
- Button
- Layout
- Footer
- Text
- Box
- Card
- Table
- Loading
- Select
- Loader
- Toolbar
- Icon
- CodeInput
- BottomSheet
- InfoBlock
- LanguageToggle
- ProgressCircles
- Ripple
- Toggle
- Tag
- Input
- Paginator
- Filter
- AsyncSelect
- CatalogBigButton
- ReadMore
- ConditionalWrapper
- LastCheckedDisplay
- PriceLabel
- PageTitle
- CartTable
- CartFinalPriceTable
- LoadingSpin
- InfoModal
- ProductCard
- RecommendCoupon
- PriceVales
- NomalLayout
- Web3ReactManager
- Popups
- CurrencyInput
- TransactionErrorContent
- TransactionConfirmationModal
- ConfirmationModalContent
- DoubleCurrencyLogo
- CustomModal
- CurrencySearchModal
- CurrencyLogo
- NumericalInput
- Logo
- QuestionHelper
- ListLogo
- DataTable
- WalletModal
- CustomTable
- MinimalPositionCard
- RemoveLiquidityModal
- CustomTooltip
- ColoredSlider
- ToggleSwitch
- FormattedPriceImpact
- SettingsModal
- ConfirmSwapModal
- AdvancedSwapDetails
- AddressInput
- LineChart
- StakeSyrupModal
- AccountDetails
- BetaWarningBanner
- AreaChart
- ChartType
- TokensTable
- PairTable
- TopMovers
- BarChart
- TransactionsTable
- StakeQuickModal
- UnstakeQuickModal
- SyrupCard
- CustomMenu
- SearchInput
- CustomSwitch
- FarmCard
- BuyFiatModal
- MoonpayModal
- RewardSlider
- Swap
- AddLiquidity
- PoolFinderModal
- PoolPositionCard
- SwapTokenDetails
- SuperHeader
- GlobalStyles
- PrimaryButton
- SectionTitle
- Section
- AccentSection
- ChainSelection
- CoinSelection
- AddressSelection
- SendAction
- Buttons
- Content
- Particles
- IconButton
- NotSupported
- InputSearch
- RouteGuard
- SearchBar
- FileInput
- GovBanner
- AuthForm
- DomainDetails
- Subnav
- ColumnFilter
- ImportExport
- selectFilter
- TaggedArrayInput
- FacetFilter
- ButtonSingleLine
- TextMultiline
- ButtonSelect
- BottomSheetBehavior
- InfoButton
- BulletPointX
- BulletPointCheck
- Title
- LoadingIcon
- SelectFilterControls
- CORInputForm
- SdnInputForm
- Navbar
- HomeRoute
- AuthRoute
- DocumentDetails
- DocumentStepper
- AddGame
- Auth
- Effectiveness
- Export
- PokemonType
- Moves
- Member
- MoveSelector
- Type
- Natures
- Move
- PokeInfo
- Share
- Badges
- Status
- UpdateSW
- About
- Builder
- Calculator
- Changelog
- Import
- Pokestats
- Report
- Rules
- Settings
- Tracker
- DarkThemeProvider
- NotificationHandler
- Background
- Indicator
- StyledButton
- StyledText
- Illustration
- OnboardingSlider
- FlexList
- AppLayout
- ScrollableList
- Visualization
- DataSearch
- Region
- App
- CompareApiLegend
- CompareApiBreadcrumbs
- CompareApiLink
- CompareApiCard
- ExploreApiBreadcrumbs
- ExploreApiLink
- ExploreApiSearch
- ExploreApiConst
- ApiLoader
- RefreshButton
- Listing
- PriceModal
- ConfirmationModal
- Transition
- AutoComplete
- useInput
- Avatar
- Badge
- Breadcrumbs
- ButtonDropdown
- ButtonGroup
- Capacity
- Checkbox
- Code
- Collapse
- CssBaseline
- GeistProvider
- Description
- Display
- Divider
- Dot
- Drawer
- useModal
- Fieldset
- Grid
- Image
- Keyboard
- Link
- Modal
- Note
- Page
- Pagination
- Popover
- Progress
- Radio
- Rating
- Slider
- Snippet
- Spacer
- Spinner
- Tabs
- Textarea
- Tooltip
- Tree
- useBodyScroll
- useClasses
- useClickAway
- useClipboard
- useCurrentState
- useKeyboard
- KeyMod
- KeyCode
- useMediaQuery
- useTabs
- useToasts
- User
- useTheme
- Themes
- GeistUIThemes
- useAllThemes
- CollapsableDialog
- Map
- IPForm
- IPMenu
- Container
- Parallax
- Nav
- SEO
- BlogNav
- ExtensionCard
- MenuComp
Other Related APIs
components#Avatar TypeScript Examples
The following examples show how to use
components#Avatar.
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.test.tsx From geist-ui with MIT License | 5 votes |
describe('Avatar', () => {
it('should support square and circle', () => {
const circle = shallow(<Avatar />)
expect(() => circle.unmount()).not.toThrow()
const square = shallow(<Avatar isSquare />)
expect(() => square.unmount()).not.toThrow()
})
it('should render text element', () => {
const imageAvatar = render(<Avatar />)
expect(imageAvatar).toMatchSnapshot()
const textAvatar = render(<Avatar text="text" />)
expect(textAvatar).toMatchSnapshot()
})
it('should omit long chars automatically', () => {
const avatar = mount(<Avatar text="texttexttexttext" />)
const text = avatar.find('.avatar-text').text()
expect(text.length).toBeLessThan(4)
})
it('stacked should be work', () => {
const avatar = shallow(<Avatar src="/images/avatar.png" stacked />)
expect(() => avatar.unmount()).not.toThrow()
})
it('group component should render all children', () => {
const group = mount(
<Avatar.Group>
<Avatar />
<Avatar />
</Avatar.Group>,
)
expect(group.find('.avatar')).toHaveLength(2)
})
it('should stacked when avatars are in a group', () => {
const group = render(
<Avatar.Group>
<Avatar />
<Avatar />
</Avatar.Group>,
)
expect(group).toMatchSnapshot()
})
it('should show count in group', () => {
const count = 20
const group = render(<Avatar.Group count={count} />)
const text = group.find('.count').text()
expect(text).toMatch(`${count}`)
})
})
Example #2
Source File: contributors.tsx From geist-ui with MIT License | 5 votes |
Contributors: React.FC<Props> = ({ path }) => {
const { isChinese } = useConfigs()
const [users, setUsers] = useState<Array<Contributor>>([])
const link = useMemo(() => `${RepoMasterURL}/${path || '/pages'}`, [])
useEffect(() => {
let unmount = false
;(async () => {
const contributors = await getContributors(path)
if (unmount) return
setUsers(contributors)
})()
return () => {
unmount = true
}
}, [])
return (
<div className="contributors">
{users.map((user, index) => (
<Tooltip leaveDelay={0} text={<b>{user.name}</b>} key={`${user.url}-${index}`}>
<Link color target="_blank" rel="nofollow" href={user.url}>
<Avatar src={user.avatar} />
</Link>
</Tooltip>
))}
<Tooltip
leaveDelay={0}
text={isChinese ? '在 GitHub 上编辑此页面' : 'Edit this page on GitHub'}
type="dark">
<Link color target="_blank" rel="nofollow" href={link}>
<Avatar text="Add" />
</Link>
</Tooltip>
<style jsx>{`
.contributors {
padding-left: 5px;
padding-top: 5px;
max-width: 100%;
height: auto;
display: flex;
flex-wrap: wrap;
}
.contributors :global(.tooltip) {
margin-right: 5px;
}
`}</style>
</div>
)
}