From bc9fcd790964495399cbaf87ce267c2e371ade2d Mon Sep 17 00:00:00 2001 From: Mariela Tihova Date: Mon, 26 Jan 2026 13:19:51 +0200 Subject: [PATCH 1/2] feat(switch): Add Styling sample --- .../styling/.devcontainer/devcontainer.json | 4 + samples/inputs/switches/styling/.eslintrc.js | 75 +++++++++++++++++++ samples/inputs/switches/styling/README.md | 56 ++++++++++++++ samples/inputs/switches/styling/index.html | 11 +++ samples/inputs/switches/styling/package.json | 42 +++++++++++ .../switches/styling/sandbox.config.json | 5 ++ samples/inputs/switches/styling/src/index.css | 15 ++++ samples/inputs/switches/styling/src/index.tsx | 18 +++++ samples/inputs/switches/styling/tsconfig.json | 44 +++++++++++ .../inputs/switches/styling/vite.config.js | 12 +++ 10 files changed, 282 insertions(+) create mode 100644 samples/inputs/switches/styling/.devcontainer/devcontainer.json create mode 100644 samples/inputs/switches/styling/.eslintrc.js create mode 100644 samples/inputs/switches/styling/README.md create mode 100644 samples/inputs/switches/styling/index.html create mode 100644 samples/inputs/switches/styling/package.json create mode 100644 samples/inputs/switches/styling/sandbox.config.json create mode 100644 samples/inputs/switches/styling/src/index.css create mode 100644 samples/inputs/switches/styling/src/index.tsx create mode 100644 samples/inputs/switches/styling/tsconfig.json create mode 100644 samples/inputs/switches/styling/vite.config.js diff --git a/samples/inputs/switches/styling/.devcontainer/devcontainer.json b/samples/inputs/switches/styling/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..e0b8e9c925 --- /dev/null +++ b/samples/inputs/switches/styling/.devcontainer/devcontainer.json @@ -0,0 +1,4 @@ +{ + "name": "Node.js", + "image": "mcr.microsoft.com/devcontainers/javascript-node:22" +} \ No newline at end of file diff --git a/samples/inputs/switches/styling/.eslintrc.js b/samples/inputs/switches/styling/.eslintrc.js new file mode 100644 index 0000000000..b45160a9ee --- /dev/null +++ b/samples/inputs/switches/styling/.eslintrc.js @@ -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" + } + } + ] + }; \ No newline at end of file diff --git a/samples/inputs/switches/styling/README.md b/samples/inputs/switches/styling/README.md new file mode 100644 index 0000000000..4fabc5d775 --- /dev/null +++ b/samples/inputs/switches/styling/README.md @@ -0,0 +1,56 @@ + + + +This folder contains implementation of React application with example of Styling feature using [Switches](https://www.infragistics.com/products/ignite-ui-react/react/components/general-getting-started.html) component. + + + + + + View Docs + + + View Code + + + Run Sample + + + Run Sample + + + + +## 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/inputs/switches/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). diff --git a/samples/inputs/switches/styling/index.html b/samples/inputs/switches/styling/index.html new file mode 100644 index 0000000000..304d0bb440 --- /dev/null +++ b/samples/inputs/switches/styling/index.html @@ -0,0 +1,11 @@ + + + + SwitchChecking + + + +
+ + + \ No newline at end of file diff --git a/samples/inputs/switches/styling/package.json b/samples/inputs/switches/styling/package.json new file mode 100644 index 0000000000..87113634e4 --- /dev/null +++ b/samples/inputs/switches/styling/package.json @@ -0,0 +1,42 @@ +{ + "name": "react-switch-checking", + "description": "This project provides example of Switch Checking using Infragistics React components", + "author": "Infragistics", + "homepage": ".", + "version": "1.4.0", + "private": true, + "scripts": { + "start": "vite --port 4200", + "build": "tsc && node --max-old-space-size=4096 node_modules/vite/bin/vite build", + "preview": "vite preview", + "test": "vitest" + }, + "dependencies": { + "igniteui-dockmanager": "^1.17.0", + "igniteui-react": "^19.4.0", + "igniteui-react-core": "19.3.1", + "igniteui-webcomponents": "^6.3.0", + "react": "^19.2.0", + "react-dom": "^19.2.0", + "tslib": "^2.4.0" + }, + "devDependencies": { + "@types/jest": "^29.2.0", + "@types/node": "^24.7.1", + "@types/react": "^18.0.24", + "@types/react-dom": "^18.0.8", + "@vitejs/plugin-react": "^5.0.4", + "@vitest/browser": "^3.2.4", + "typescript": "^4.8.4", + "vite": "^7.1.9", + "vitest": "^3.2.4", + "vitest-canvas-mock": "^0.3.3", + "worker-loader": "^3.0.8" + }, + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ] +} diff --git a/samples/inputs/switches/styling/sandbox.config.json b/samples/inputs/switches/styling/sandbox.config.json new file mode 100644 index 0000000000..00acba0c10 --- /dev/null +++ b/samples/inputs/switches/styling/sandbox.config.json @@ -0,0 +1,5 @@ +{ + "infiniteLoopProtection": false, + "hardReloadOnChange": false, + "view": "browser" +} \ No newline at end of file diff --git a/samples/inputs/switches/styling/src/index.css b/samples/inputs/switches/styling/src/index.css new file mode 100644 index 0000000000..94cb703b97 --- /dev/null +++ b/samples/inputs/switches/styling/src/index.css @@ -0,0 +1,15 @@ +/* shared styles are loaded from: */ +/* https://dl.infragistics.com/x/css/samples/shared.v8.css */ + +igc-switch::part(thumb) { + background-color: var(--ig-success-500); + box-shadow: none; + } + + igc-switch::part(thumb checked) { + background-color: var(--ig-gray-50); + } + + igc-switch::part(control checked) { + background-color: var(--ig-success-500); + } \ No newline at end of file diff --git a/samples/inputs/switches/styling/src/index.tsx b/samples/inputs/switches/styling/src/index.tsx new file mode 100644 index 0000000000..db4492f79e --- /dev/null +++ b/samples/inputs/switches/styling/src/index.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import './index.css'; +import { IgrSwitch } from 'igniteui-react'; +import 'igniteui-webcomponents/themes/light/bootstrap.css'; + +export default function SwitchStyling() { + + return ( +
+ Label +
+ ); +} + +// rendering above component to the React DOM +const root = ReactDOM.createRoot(document.getElementById('root')); +root.render(); diff --git a/samples/inputs/switches/styling/tsconfig.json b/samples/inputs/switches/styling/tsconfig.json new file mode 100644 index 0000000000..e7db8a94f5 --- /dev/null +++ b/samples/inputs/switches/styling/tsconfig.json @@ -0,0 +1,44 @@ +{ + "compilerOptions": { + "resolveJsonModule": true, + "esModuleInterop": true, + "baseUrl": ".", + "outDir": "build/dist", + "module": "esnext", + "target": "es5", + "lib": [ + "es6", + "dom" + ], + "sourceMap": true, + "allowJs": true, + "jsx": "react", + "moduleResolution": "node", + "rootDir": "src", + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noImplicitAny": true, + "noUnusedLocals": false, + "importHelpers": true, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "strict": false, + "isolatedModules": true, + "noEmit": true + }, + "exclude": [ + "node_modules", + "build", + "scripts", + "acceptance-tests", + "webpack", + "jest", + "src/setupTests.ts", + "**/odatajs-4.0.0.js", + "config-overrides.js" + ], + "include": [ + "src" + ] +} diff --git a/samples/inputs/switches/styling/vite.config.js b/samples/inputs/switches/styling/vite.config.js new file mode 100644 index 0000000000..1744dbc719 --- /dev/null +++ b/samples/inputs/switches/styling/vite.config.js @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [react()], + build: { + outDir: 'build' + }, + server: { + open: false + }, +}); \ No newline at end of file From 0b0f02fa63255069ebfa77da2b7c4ff871c83344 Mon Sep 17 00:00:00 2001 From: Mariela Tihova Date: Wed, 28 Jan 2026 18:28:13 +0200 Subject: [PATCH 2/2] fix(switch): updating css to use vars --- samples/inputs/switches/styling/src/index.css | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/samples/inputs/switches/styling/src/index.css b/samples/inputs/switches/styling/src/index.css index 94cb703b97..fc42274b5e 100644 --- a/samples/inputs/switches/styling/src/index.css +++ b/samples/inputs/switches/styling/src/index.css @@ -1,15 +1,10 @@ /* shared styles are loaded from: */ /* https://dl.infragistics.com/x/css/samples/shared.v8.css */ -igc-switch::part(thumb) { - background-color: var(--ig-success-500); - box-shadow: none; + igc-switch { + --thumb-on-color: white; + --thumb-off-color: var(--ig-success-500); + --track-on-color: var(--ig-success-500); /* Background color when checked */ + --track-off-color: white; /* Background color when unchecked */ + --track-on-hover-color: var(--ig-success-500); /* Background hover color when checked */ } - - igc-switch::part(thumb checked) { - background-color: var(--ig-gray-50); - } - - igc-switch::part(control checked) { - background-color: var(--ig-success-500); - } \ No newline at end of file