|
1 | | -import React from 'react'; |
2 | | -import ReactDOM from 'react-dom/client'; |
3 | | -import './index.css'; |
4 | | -import './CardOverview.css'; |
| 1 | +import React, { useEffect } from "react"; |
| 2 | +import ReactDOM from "react-dom/client"; |
| 3 | +import "./index.css"; |
| 4 | +import "./CardOverview.css"; |
5 | 5 | import { |
6 | | - IgrCard, IgrCardMedia, IgrCardHeader, |
7 | | - IgrCardContent, IgrCardActions, IgrCardModule, |
8 | | - IgrIconButton, IgrIconButtonModule, IgrButton, |
9 | | - IgrButtonModule, IgrRipple, IgrRippleModule, |
10 | | - registerIconFromText, |
11 | | -} from 'igniteui-react'; |
12 | | -import 'igniteui-webcomponents/themes/light/bootstrap.css'; |
| 6 | + IgrCard, |
| 7 | + IgrCardMedia, |
| 8 | + IgrCardHeader, |
| 9 | + IgrCardContent, |
| 10 | + IgrCardActions, |
| 11 | + IgrIconButton, |
| 12 | + IgrButton, |
| 13 | + IgrRipple, |
| 14 | + registerIconFromText, |
| 15 | +} from "igniteui-react"; |
| 16 | +import "igniteui-webcomponents/themes/light/bootstrap.css"; |
13 | 17 |
|
14 | | -IgrCardModule.register(); |
15 | | -IgrButtonModule.register(); |
16 | | -IgrIconButtonModule.register(); |
17 | | -IgrRippleModule.register(); |
| 18 | +const twitterIcon = |
| 19 | + '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 3H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V5a2 2 0 00-2-2zm-1.13 6v.39a8.61 8.61 0 01-13.25 7.25 5.69 5.69 0 00.72 0 6 6 0 003.76-1.3 3 3 0 01-2.83-2.1 2.75 2.75 0 00.57.05 3 3 0 00.8-.1 3 3 0 01-2.43-3 3.13 3.13 0 001.37.38 3 3 0 01-.93-4 8.57 8.57 0 006.24 3.17 3.1 3.1 0 01-.08-.74 3 3 0 015.24-2A6.38 6.38 0 0019 6.22a3.07 3.07 0 01-1.36 1.68 6.22 6.22 0 001.74-.48A6.09 6.09 0 0117.87 9z"></path></svg>'; |
| 20 | +const facebookIcon = |
| 21 | + '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 22zm0-20a10 10 0 00-1.727 19.841v-7.6h-2.61v-3.018h2.61V8.995A3.641 3.641 0 0114.16 5a21.367 21.367 0 012.332.119v2.7h-1.6c-1.255 0-1.5.6-1.5 1.471v1.929h2.993L16 14.245h-2.6v7.647A9.994 9.994 0 0012 2z"></path></svg>'; |
18 | 22 |
|
19 | | -const twitterIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 3H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V5a2 2 0 00-2-2zm-1.13 6v.39a8.61 8.61 0 01-13.25 7.25 5.69 5.69 0 00.72 0 6 6 0 003.76-1.3 3 3 0 01-2.83-2.1 2.75 2.75 0 00.57.05 3 3 0 00.8-.1 3 3 0 01-2.43-3 3.13 3.13 0 001.37.38 3 3 0 01-.93-4 8.57 8.57 0 006.24 3.17 3.1 3.1 0 01-.08-.74 3 3 0 015.24-2A6.38 6.38 0 0019 6.22a3.07 3.07 0 01-1.36 1.68 6.22 6.22 0 001.74-.48A6.09 6.09 0 0117.87 9z"></path></svg>'; |
20 | | -const facebookIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 22zm0-20a10 10 0 00-1.727 19.841v-7.6h-2.61v-3.018h2.61V8.995A3.641 3.641 0 0114.16 5a21.367 21.367 0 012.332.119v2.7h-1.6c-1.255 0-1.5.6-1.5 1.471v1.929h2.993L16 14.245h-2.6v7.647A9.994 9.994 0 0012 2z"></path></svg>'; |
| 23 | +export default function CardOverview() { |
| 24 | + useEffect(() => { |
| 25 | + registerIconFromText("twitter", twitterIcon, "material"); |
| 26 | + registerIconFromText("facebook", facebookIcon, "material"); |
| 27 | + }, []); |
21 | 28 |
|
22 | | -export default class CardOverview extends React.Component<any, any> { |
23 | | - |
24 | | - constructor(props: any) { |
25 | | - super(props); |
26 | | - registerIconFromText("twitter", twitterIcon, "material"); |
27 | | - registerIconFromText("facebook", facebookIcon, "material"); |
28 | | - } |
29 | | - |
30 | | - public render(): JSX.Element { |
31 | | - return ( |
32 | | - <div className="container sample center"> |
33 | | - <div className="card-wrapper"> |
34 | | - <IgrCard> |
35 | | - <IgrCardMedia key="media"> |
36 | | - <img key="mediaImg" src="https://images.unsplash.com/photo-1518235506717-e1ed3306a89b?ixlib=rb-1.2.1&auto=format&fit=crop&w=640&q=50"></img> |
37 | | - </IgrCardMedia> |
38 | | - |
39 | | - <IgrCardHeader key="header"> |
40 | | - <h3 key="headerTitle" slot="title">New York City</h3> |
41 | | - <h5 key="headerSubtitle" slot="subtitle">City in New York</h5> |
42 | | - </IgrCardHeader> |
43 | | - |
44 | | - <IgrCardContent key="content"> |
45 | | - <p key="contentParagraph">New York City comprises 5 boroughs sitting where the |
46 | | - Hudson River meets the Atlantic Ocean. At its core is Manhattan, |
47 | | - a densely populated borough that’s among the world’s major commercial, |
48 | | - financial and cultural centers.</p> |
49 | | - </IgrCardContent> |
50 | | - |
51 | | - <IgrCardActions key="actions"> |
52 | | - <IgrButton key="actionsBtn"> |
53 | | - <span key="btnSpan">Read more</span> |
54 | | - <IgrRipple key="btnRipple" /> |
55 | | - </IgrButton> |
56 | | - <div slot="end" key="endSlot"> |
57 | | - <IgrIconButton key="twitterIcon" style={{marginRight: "10px"}} name="twitter" collection="material"> |
58 | | - <IgrRipple key="twitterRipple"/> |
59 | | - </IgrIconButton> |
60 | | - <IgrIconButton key="fbIcon" name="facebook" collection="material"> |
61 | | - <IgrRipple key="fbRipple"/> |
62 | | - </IgrIconButton> |
63 | | - </div> |
64 | | - </IgrCardActions> |
65 | | - </IgrCard> |
66 | | - </div> |
| 29 | + return ( |
| 30 | + <div className="container sample center"> |
| 31 | + <div className="card-wrapper"> |
| 32 | + <IgrCard> |
| 33 | + <IgrCardMedia> |
| 34 | + <img src="https://images.unsplash.com/photo-1518235506717-e1ed3306a89b?ixlib=rb-1.2.1&auto=format&fit=crop&w=640&q=50"></img> |
| 35 | + </IgrCardMedia> |
| 36 | + <IgrCardHeader> |
| 37 | + <h3 slot="title">New York City</h3> |
| 38 | + <h5 slot="subtitle">City in New York</h5> |
| 39 | + </IgrCardHeader> |
| 40 | + <IgrCardContent> |
| 41 | + <p> |
| 42 | + New York City comprises 5 boroughs sitting where the Hudson River |
| 43 | + meets the Atlantic Ocean. At its core is Manhattan, a densely |
| 44 | + populated borough that’s among the world’s major commercial, |
| 45 | + financial and cultural centers. |
| 46 | + </p> |
| 47 | + </IgrCardContent> |
| 48 | + <IgrCardActions> |
| 49 | + <IgrButton> |
| 50 | + <span>Read more</span> |
| 51 | + <IgrRipple /> |
| 52 | + </IgrButton> |
| 53 | + <div slot="end"> |
| 54 | + <IgrIconButton |
| 55 | + style={{ marginRight: "10px" }} |
| 56 | + name="twitter" |
| 57 | + collection="material" |
| 58 | + > |
| 59 | + <IgrRipple /> |
| 60 | + </IgrIconButton> |
| 61 | + <IgrIconButton name="facebook" collection="material"> |
| 62 | + <IgrRipple /> |
| 63 | + </IgrIconButton> |
67 | 64 | </div> |
68 | | - ); |
69 | | - } |
| 65 | + </IgrCardActions> |
| 66 | + </IgrCard> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + ); |
70 | 70 | } |
71 | 71 |
|
72 | | -// rendering above class to the React DOM |
73 | | -const root = ReactDOM.createRoot(document.getElementById('root')); |
74 | | -root.render(<CardOverview/>); |
| 72 | +// rendering above component to the React DOM |
| 73 | +const root = ReactDOM.createRoot(document.getElementById("root")); |
| 74 | +root.render(<CardOverview />); |
0 commit comments