Skip to content

docs(avatar): add component playgrounds and new svg #2524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 13 additions & 168 deletions docs/api/avatar.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
title: "ion-avatar"
hide_table_of_contents: true
demoUrl: "/docs/demos/api/avatar/index.html"
demoSourceUrl: "https://github.com/ionic-team/ionic-docs/tree/main/static/demos/api/avatar/index.html"
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import Props from '@site/static/auto-generated/avatar/props.md';
import Events from '@site/static/auto-generated/avatar/events.md';
Expand All @@ -20,186 +15,36 @@ import Slots from '@site/static/auto-generated/avatar/slots.md';
</head>

import EncapsulationPill from '@components/page/api/EncapsulationPill';
import APITOCInline from '@components/page/api/APITOCInline';

<EncapsulationPill type="shadow" />

<h2 className="table-of-contents__title">Contents</h2>

<APITOCInline
toc={toc}
maxHeadingLevel={2}
autogenerated={[Props, Events, Methods, Parts, CustomProps, Slots]}
/>



Avatars are circular components that usually wrap an image or icon. They can be used to represent a person or an object.

Avatars can be used by themselves or inside of any element. If placed inside of an `ion-chip` or `ion-item`, the avatar will resize to fit the parent component. To position an avatar on the left or right side of an item, set the slot to `start` or `end`, respectively.

## Basic

import Basic from '@site/static/usage/avatar/basic/index.md';

<Basic />

## Usage
## Chip Avatar

<Tabs groupId="framework" defaultValue="angular" values={[{ value: 'angular', label: 'Angular' }, { value: 'javascript', label: 'Javascript' }, { value: 'react', label: 'React' }, { value: 'stencil', label: 'Stencil' }, { value: 'vue', label: 'Vue' }]}>
import Chip from '@site/static/usage/avatar/chip/index.md';

<TabItem value="angular">
<Chip />

```html
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
## Item Avatar

<ion-chip>
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>

<ion-item>
<ion-avatar slot="start">
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
<ion-label>Item Avatar</ion-label>
</ion-item>
```
import Item from '@site/static/usage/avatar/item/index.md';

</TabItem>
<Item />

## Theming

<TabItem value="javascript">
import Theming from '@site/static/usage/avatar/theming/index.md';

```html
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>

<ion-chip>
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>

<ion-item>
<ion-avatar slot="start">
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
<ion-label>Item Avatar</ion-label>
</ion-item>
```

</TabItem>


<TabItem value="react">

```tsx
import React from 'react';
import { IonAvatar, IonChip, IonItem, IonLabel, IonContent } from '@ionic/react';

export const AvatarExample: React.FC = () => (
<IonContent>
<IonAvatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y" />
</IonAvatar>

<IonChip>
<IonAvatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y" />
</IonAvatar>
<IonLabel>Chip Avatar</IonLabel>
</IonChip>

<IonItem>
<IonAvatar slot="start">
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y" />
</IonAvatar>
<IonLabel>Item Avatar</IonLabel>
</IonItem>
</IonContent>
);
```

</TabItem>


<TabItem value="stencil">

```tsx
import { Component, h } from '@stencil/core';

@Component({
tag: 'avatar-example',
styleUrl: 'avatar-example.css'
})
export class AvatarExample {
render() {
return [
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y"/>
</ion-avatar>,

<ion-chip>
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y"/>
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>,

<ion-item>
<ion-avatar slot="start">
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y"/>
</ion-avatar>
<ion-label>Item Avatar</ion-label>
</ion-item>
];
}
}
```

</TabItem>


<TabItem value="vue">

```html
<template>
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>

<ion-chip>
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>

<ion-item>
<ion-avatar slot="start">
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y">
</ion-avatar>
<ion-label>Item Avatar</ion-label>
</ion-item>
</template>

<script>
import { IonAvatar, IonChip, IonItem, IonLabel } from '@ionic/vue';
import { defineComponent } from 'vue';

export default defineComponent({
components: { IonAvatar, IonChip, IonItem, IonLabel }
});
</script>
```

</TabItem>

</Tabs>
<Theming />

## Properties
<Props />
Expand All @@ -217,4 +62,4 @@ export default defineComponent({
<CustomProps />

## Slots
<Slots />
<Slots />
13 changes: 12 additions & 1 deletion static/demos/api/avatar/avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion static/img/avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions static/usage/avatar/basic/angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```html
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
```
27 changes: 27 additions & 0 deletions static/usage/avatar/basic/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Avatar</title>
<link rel="stylesheet" href="../../common.css" />
<script src="../../common.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@6/dist/ionic/ionic.esm.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@6/css/ionic.bundle.css" />

</head>

<body>
<ion-app>
<ion-content>
<div class="container">
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
</div>
</ion-content>
</ion-app>
</body>

</html>
8 changes: 8 additions & 0 deletions static/usage/avatar/basic/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Playground from '@site/src/components/global/Playground';

import javascript from './javascript.md';
import react from './react.md';
import vue from './vue.md';
import angular from './angular.md';

<Playground code={{ javascript, react, vue, angular }} src="usage/avatar/basic/demo.html" />
5 changes: 5 additions & 0 deletions static/usage/avatar/basic/javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```html
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
```
15 changes: 15 additions & 0 deletions static/usage/avatar/basic/react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```tsx
import React from 'react';
import { IonAvatar } from '@ionic/react';

function Example() {
return (
<>
<IonAvatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</IonAvatar>
</>
);
}
export default Example;
```
16 changes: 16 additions & 0 deletions static/usage/avatar/basic/vue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```html
<template>
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
</template>

<script lang="ts">
import { IonAvatar } from '@ionic/vue';
import { defineComponent } from 'vue';

export default defineComponent({
components: { IonAvatar },
});
</script>
```
8 changes: 8 additions & 0 deletions static/usage/avatar/chip/angular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```html
<ion-chip>
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>
```
30 changes: 30 additions & 0 deletions static/usage/avatar/chip/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Avatar</title>
<link rel="stylesheet" href="../../common.css" />
<script src="../../common.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@6/dist/ionic/ionic.esm.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@6/css/ionic.bundle.css" />

</head>

<body>
<ion-app>
<ion-content>
<div class="container">
<ion-chip>
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>
</div>
</ion-content>
</ion-app>
</body>

</html>
8 changes: 8 additions & 0 deletions static/usage/avatar/chip/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Playground from '@site/src/components/global/Playground';

import javascript from './javascript.md';
import react from './react.md';
import vue from './vue.md';
import angular from './angular.md';

<Playground code={{ javascript, react, vue, angular }} src="usage/avatar/chip/demo.html" />
8 changes: 8 additions & 0 deletions static/usage/avatar/chip/javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```html
<ion-chip>
<ion-avatar>
<img alt="Silhouette of a person's head" src="https://ionicframework.com/docs/demos/api/avatar/avatar.svg" />
</ion-avatar>
<ion-label>Chip Avatar</ion-label>
</ion-chip>
```
Loading