Skip to content

Commit ae5a2bd

Browse files
committed
[WIP][FEAT]: Add smart image fit and API section to Avatar demo page
1 parent 088099c commit ae5a2bd

File tree

3 files changed

+121
-2
lines changed

3 files changed

+121
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as React from "react";
2+
import ShowDemoCode from "../../show-demo-code/ShowDemoCode";
3+
interface CodeDemoAvatarPickFileProps {}
4+
const CodeDemoAvatarSmartFit: React.FC<CodeDemoAvatarPickFileProps> = (
5+
props: CodeDemoAvatarPickFileProps
6+
) => {
7+
return (
8+
<ShowDemoCode
9+
codeCompleteJS={completeCodeJS}
10+
codeCompleteTS={completeCodeTS}
11+
codeSandboxJS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
12+
codeSandboxTS="https://codesandbox.io/s/dropzone-ui-basic-3j01v"
13+
codeSplittedJS={splittedCodeJS}
14+
codeSplittedTS={splittedCodeTS}
15+
/>
16+
);
17+
};
18+
export default CodeDemoAvatarSmartFit;
19+
20+
const splittedCodeJS = ``;
21+
const splittedCodeTS = splittedCodeJS;
22+
const completeCodeJS = `import * as React from "react";
23+
import { Avatar } from "@files-ui/react";
24+
const landscapeImage =
25+
"https://64.media.tumblr.com/078a5af7a51d438b1c1ee5bd77f1b1e5/tumblr_p81qv7KIPa1rvufhzo3_r1_400.gif";
26+
27+
const portraitImage =
28+
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif";
29+
30+
export default function App = () => {
31+
return (
32+
<>
33+
<Avatar src={landscapeImage} readOnly smartImgFit={false} />
34+
<Avatar src={landscapeImage} readOnly smartImgFit={"orientation"} />
35+
<Avatar src={landscapeImage} readOnly smartImgFit={"center"} />
36+
37+
<Avatar src={portraitImage} readOnly smartImgFit={false} />
38+
<Avatar src={portraitImage} readOnly smartImgFit={"orientation"} />
39+
<Avatar src={portraitImage} readOnly smartImgFit={"center"} />
40+
</>
41+
);
42+
};`;
43+
44+
const completeCodeTS = completeCodeJS;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as React from "react";
2+
import { Avatar, AvatarProps } from "../../../files-ui";
3+
interface DemoAvatarFallBackProps {}
4+
5+
const landscapeImage =
6+
"https://64.media.tumblr.com/078a5af7a51d438b1c1ee5bd77f1b1e5/tumblr_p81qv7KIPa1rvufhzo3_r1_400.gif";
7+
8+
const portraitImage =
9+
"https://i.pinimg.com/originals/b6/1d/6a/b61d6a1079d8e54932dcde9dc260dd2e.gif";
10+
11+
const DemoAvatarSmartImgFit: React.FC<DemoAvatarFallBackProps> = (
12+
props: DemoAvatarFallBackProps
13+
) => {
14+
return (
15+
<>
16+
<Avatar src={landscapeImage} readOnly smartImgFit={false} />
17+
<Avatar src={landscapeImage} readOnly smartImgFit={"orientation"} />
18+
<Avatar src={landscapeImage} readOnly smartImgFit={"center"} />
19+
20+
<Avatar src={portraitImage} readOnly smartImgFit={false} />
21+
<Avatar src={portraitImage} readOnly smartImgFit={"orientation"} />
22+
<Avatar src={portraitImage} readOnly smartImgFit={"center"} />
23+
</>
24+
);
25+
};
26+
export default DemoAvatarSmartImgFit;

src/pages/demo/AvatarDemoPage.tsx

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import DemoAvatarPickFile from "../../components/demo-components/avatar-demo/Dem
1515
import CodeDemoAvatarPickFile from "../../components/demo-components/avatar-demo/CodeDemoAvatarPickFile";
1616
import DemoAvatarFallBack from "../../components/demo-components/avatar-demo/DemoAvatarFallBack";
1717
import CodeDemoAvatarFallBack from "../../components/demo-components/avatar-demo/CodeDemoAvatarFallBack";
18+
import AnchorToTab from "../../components/util-components/AnchorToTab";
19+
import DemoAvatarSmartImgFit from "../../components/demo-components/avatar-demo/DmoAvatarSmartImgFit";
20+
import CodeDemoAvatarSmartFit from "../../components/demo-components/avatar-demo/CodeDemoAvatarSmartFit";
1821

1922
interface AvatarDemoPageProps {}
2023
const AvatarDemoPage: React.FC<AvatarDemoPageProps> = (
@@ -92,12 +95,58 @@ const AvatarDemoPage: React.FC<AvatarDemoPageProps> = (
9295
display: "flex",
9396
width: "100%",
9497
justifyContent: "space-evenly",
98+
flexWrap: "wrap",
99+
gap: "5px",
95100
}}
96101
>
97102
<DemoAvatarFallBack />
98103
</Paper>
99104
<CodeDemoAvatarFallBack />
100105
</section>
106+
107+
<section id="smart-image-fit">
108+
<SubTitle content="Smart image fit" />
109+
<DescParagraph>
110+
<CodeHighlight>Avatar</CodeHighlight> with
111+
<TypeHighlight>smartImgFit</TypeHighlight> prop will display image
112+
according to its heigh and width.
113+
<br />
114+
Image with height greater than its width has a "portrait"
115+
orientation. Otherwise it has a "landscape" orientation.
116+
<br />
117+
In Avatar component the default value is "center".
118+
</DescParagraph>
119+
120+
<Paper
121+
variant="outlined"
122+
style={{
123+
padding: "25px",
124+
//padding:"auto",
125+
display: "flex",
126+
width: "100%",
127+
justifyContent: "space-evenly",
128+
flexWrap: "wrap",
129+
gap: "50px",
130+
}}
131+
>
132+
<DemoAvatarSmartImgFit />
133+
</Paper>
134+
135+
<CodeDemoAvatarSmartFit />
136+
</section>
137+
138+
<section id="api">
139+
<SubTitle content="API" />
140+
<DescParagraph>
141+
See the documentation below for a complete reference to all of the
142+
props available to the components mentioned here.
143+
</DescParagraph>
144+
<ul>
145+
<li>
146+
<AnchorToTab href="/api/avatar">{"<Avatar/>"}</AnchorToTab>
147+
</li>
148+
</ul>
149+
</section>
101150
</MainContentContainer>
102151

103152
<RightMenuContainer>
@@ -127,7 +176,7 @@ const rightMenuItems = [
127176
{
128177
id: 4,
129178
label: "Smart image fit",
130-
referTo: "/components/filemosaic#smart-image-fit",
179+
referTo: "/components/avatar#smart-image-fit",
131180
},
132181
{
133182
id: 5,
@@ -152,6 +201,6 @@ const rightMenuItems = [
152201
{
153202
id: 9,
154203
label: "API",
155-
referTo: "/components/filecard#api",
204+
referTo: "/components/avatar#api",
156205
},
157206
];

0 commit comments

Comments
 (0)