Skip to content

refactor: Avatar samples update + adding styling sample for react v19 #842

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

Open
wants to merge 2 commits into
base: vnext
Choose a base branch
from
Open
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
31 changes: 13 additions & 18 deletions samples/layouts/avatar/icon/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
import React from 'react';
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrAvatarModule, IgrAvatar, IgrIcon, IgrIconModule, registerIconFromText } from 'igniteui-react';
import { IgrAvatar, IgrIcon, registerIconFromText } from 'igniteui-react';
import 'igniteui-webcomponents/themes/light/bootstrap.css';

IgrAvatarModule.register();
IgrIconModule.register();

const homeIcon =
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>';

export default class AvatarIcon extends React.Component<any, any> {
export default function AvatarIcon() {

constructor(props: any) {
super(props);
useEffect(() => {
registerIconFromText("home", homeIcon, "material");
}
}, []);

public render(): JSX.Element {
return (
<div className="container sample">
<IgrAvatar>
<IgrIcon key="icon" name="home" collection="material" />
</IgrAvatar>
</div>
);
}
return (
<div className="container sample">
<IgrAvatar>
<IgrIcon name="home" collection="material" />
</IgrAvatar>
</div>
);
}

// rendering above class to the React DOM
// rendering above component to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<AvatarIcon/>);
24 changes: 8 additions & 16 deletions samples/layouts/avatar/image/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrAvatarModule, IgrAvatar } from 'igniteui-react';
import { IgrAvatar } from 'igniteui-react';
import 'igniteui-webcomponents/themes/light/bootstrap.css';

IgrAvatarModule.register();
export default function AvatarImage() {

export default class AvatarImage extends React.Component<any, any> {

constructor(props: any) {
super(props);
}

public render(): JSX.Element {
return (
<div className="container sample">
<IgrAvatar src="https://static.infragistics.com/xplatform/images/people/men/1.jpg" alt="A photo of a man." />
</div>
);
}
return (
<div className="container sample">
<IgrAvatar src="https://static.infragistics.com/xplatform/images/people/men/1.jpg" alt="A photo of a man." />
</div>
);
}

// rendering above class to the React DOM
// rendering above component to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<AvatarImage/>);
24 changes: 8 additions & 16 deletions samples/layouts/avatar/initials/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrAvatarModule, IgrAvatar } from 'igniteui-react';
import { IgrAvatar } from 'igniteui-react';
import 'igniteui-webcomponents/themes/light/bootstrap.css';

IgrAvatarModule.register();
export default function AvatarInitials() {

export default class AvatarInitials extends React.Component<any, any> {

constructor(props: any) {
super(props);
}

public render(): JSX.Element {
return (
<div className="container sample">
<IgrAvatar initials="AZ"/>
</div>
);
}
return (
<div className="container sample">
<IgrAvatar initials="AZ"/>
</div>
);
}

// rendering above class to the React DOM
// rendering above component to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<AvatarInitials/>);
34 changes: 14 additions & 20 deletions samples/layouts/avatar/shape/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
import React from 'react';
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrAvatarModule, IgrAvatar, IgrIcon, IgrIconModule, registerIconFromText } from 'igniteui-react';
import { IgrAvatar, IgrIcon, registerIconFromText } from 'igniteui-react';
import 'igniteui-webcomponents/themes/light/bootstrap.css';

IgrAvatarModule.register();
IgrIconModule.register();

const homeIcon =
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>';

export default class AvatarShape extends React.Component<any, any> {
export default function AvatarShape() {

constructor(props: any) {
super(props);
useEffect(() => {
registerIconFromText("home", homeIcon, "material");
}

public render(): JSX.Element {
return (
<div className="container sample">
<IgrAvatar shape="rounded">
<IgrIcon key="icon" name="home" collection="material" />
</IgrAvatar>
</div>
);
}
}, []);

return (
<div className="container sample">
<IgrAvatar shape="rounded">
<IgrIcon name="home" collection="material" />
</IgrAvatar>
</div>
);
}

// rendering above class to the React DOM
// rendering above component to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<AvatarShape/>);
28 changes: 10 additions & 18 deletions samples/layouts/avatar/size/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrAvatarModule, IgrAvatar } from 'igniteui-react';
import { IgrAvatar } from 'igniteui-react';
import 'igniteui-webcomponents/themes/light/bootstrap.css';

IgrAvatarModule.register();
export default function AvatarSize() {

export default class AvatarSize extends React.Component<any, any> {

constructor(props: any) {
super(props);
}

public render(): JSX.Element {
return (
<div className="container sample">
<IgrAvatar initials='L' className='size-large'/>
<IgrAvatar initials='M' className='size-medium'/>
<IgrAvatar initials='S' className='size-small'/>
</div>
);
}
return (
<div className="container sample">
<IgrAvatar initials='L' className='size-large'/>
<IgrAvatar initials='M' className='size-medium'/>
<IgrAvatar initials='S' className='size-small'/>
</div>
);
}

// rendering above class to the React DOM
// rendering above component to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<AvatarSize/>);
75 changes: 75 additions & 0 deletions samples/layouts/avatar/styling/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
ecmaFeatures: {
jsx: true // Allows for the parsing of JSX
}
},
settings: {
react: {
version: "999.999.999" // Tells eslint-plugin-react to automatically detect the version of React to use
}
},
extends: [
"eslint:recommended",
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
"plugin:@typescript-eslint/recommended" // Uses the recommended rules from @typescript-eslint/eslint-plugin
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"default-case": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-extend-native": "off",
"no-throw-literal": "off",
"no-useless-concat": "off",
"no-mixed-operators": "off",
"no-prototype-builtins": "off",
"prefer-const": "off",
"prefer-rest-params": "off",
"jsx-a11y/alt-text": "off",
"jsx-a11y/iframe-has-title": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"default-case": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-extend-native": "off",
"no-throw-literal": "off",
"no-useless-concat": "off",
"no-mixed-operators": "off",
"no-prototype-builtins": "off",
"prefer-const": "off",
"prefer-rest-params": "off",
"jsx-a11y/alt-text": "off",
"jsx-a11y/iframe-has-title": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
]
};
56 changes: 56 additions & 0 deletions samples/layouts/avatar/styling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!-- NOTE: do not change this file because it's auto re-generated from template: -->
<!-- https://github.com/IgniteUI/igniteui-react-examples/tree/vnext/templates/sample/ReadMe.md -->

This folder contains implementation of React application with example of Styling feature using [Avatar](https://www.infragistics.com/products/ignite-ui-react/react/components/general-getting-started.html) component.


<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<body>
<a target="_blank" href="https://www.infragistics.com/products/ignite-ui-react/react/components/general-getting-started.html" rel="noopener noreferrer">
<img height="40px" style="border-radius: 0rem" alt="View Docs" src="https://github.com/IgniteUI/igniteui-blazor-examples/raw/vnext/templates/sample/images/button-docs.png"/>
</a>
<a target="_blank" href="./src/index.tsx" rel="noopener noreferrer">
<img height="40px" style="border-radius: 0rem; max-width: 100%;" alt="View Code" src="https://github.com/IgniteUI/igniteui-blazor-examples/raw/vnext/templates/sample/images/button-code.png"/>
</a>
<a target="_blank" href="https://www.infragistics.com/react-demos/samples/layouts/avatar/styling" rel="noopener noreferrer">
<img height="40px" style="border-radius: 0rem; max-width: 100%;" alt="Run Sample" src="https://github.com/IgniteUI/igniteui-blazor-examples/raw/vnext/templates/sample/images/button-run.png"/>
</a>
<a target="_blank" href="https://codesandbox.io/s/github/IgniteUI/igniteui-react-examples/tree/master/samples/layouts/avatar/styling?fontsize=14&hidenavigation=1&theme=dark&view=preview&file=/src/index.tsx" rel="noopener noreferrer">
<img height="40px" style="border-radius: 0rem; max-width: 100%;" alt="Run Sample" src="https://github.com/IgniteUI/igniteui-blazor-examples/raw/vnext/templates/sample/images/button-sandbox.png"/>
</a>
</body>
</html>

## Branches

> **_NOTE:_** You should use [master](https://github.com/IgniteUI/igniteui-react-examples/tree/master) branch of this repository if you want to run samples on your computer. Use the [vnext](https://github.com/IgniteUI/igniteui-react-examples/tree/vnext) branch only when you want to contribute new samples to this repository.
## Instructions

Follow these instructions to run this example:


```
git clone https://github.com/IgniteUI/igniteui-react-examples.git
git checkout master
cd ./igniteui-react-examples
cd ./samples/layouts/avatar/styling
```

open above folder in VS Code or type:
```
code .
```

In terminal window, run:
```
npm install --legacy-peer-deps
npm run-script start
```

Then open http://localhost:4200/ in your browser


## Learn More

To learn more about **Ignite UI for React** components, check out the [React documentation](https://www.infragistics.com/products/ignite-ui-react/react/components/general-getting-started.html).
38 changes: 38 additions & 0 deletions samples/layouts/avatar/styling/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "react-avatar-styling",
"description": "This project provides example of Avatar Size using Infragistics React components",
"author": "Infragistics",
"homepage": ".",
"version": "1.4.0",
"private": true,
"scripts": {
"start": "set PORT=4200 && react-scripts --max_old_space_size=10240 start",
"build": "react-scripts --max_old_space_size=10240 build ",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"dependencies": {
"igniteui-dockmanager": "1.16.1",
"igniteui-react": "19.0.2",
"igniteui-react-core": "19.0.0-alpha.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/jest": "^29.2.0",
"@types/node": "^18.11.7",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"react-app-rewired": "^2.2.1",
"typescript": "^4.8.4",
"worker-loader": "^3.0.8"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
10 changes: 10 additions & 0 deletions samples/layouts/avatar/styling/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>AvatarStyling</title>
<link href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" rel="stylesheet" />
</head>
<body>
<div id="root"></div>
</body>
</html>
5 changes: 5 additions & 0 deletions samples/layouts/avatar/styling/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"infiniteLoopProtection": false,
"hardReloadOnChange": false,
"view": "browser"
}
Loading