Skip to content

feat(tailwind): add tailwind sample #1018

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 5 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
792 changes: 785 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"core-js": "^3.6.5",
"file-saver": "^2.0.2",
"igniteui-dockmanager": "1.16.0",
"igniteui-theming": "19.1.1",
"igniteui-webcomponents": "6.1.2",
"igniteui-webcomponents-charts": "6.0.1-beta.1",
"igniteui-webcomponents-core": "6.0.1-beta.1",
Expand All @@ -57,7 +58,9 @@
"igniteui-webcomponents-spreadsheet": "6.0.1-beta.1",
"igniteui-webcomponents-spreadsheet-chart-adapter": "6.0.1-beta.1",
"lit": "^3.2.0",
"lit-html": "^3.2.0"
"lit-html": "^3.2.0",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.11"
},
"devDependencies": {
"@babel/cli": "^7.8.3",
Expand All @@ -67,6 +70,7 @@
"@babel/plugin-transform-runtime": "^7.10.0",
"@babel/preset-env": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@tailwindcss/postcss": "^4.1.11",
"@types/jasmine": "^2.5.53",
"babel-loader": "^8.3.0",
"babel-plugin-transform-custom-element-classes": "^0.1.0",
Expand All @@ -92,6 +96,7 @@
"karma-chrome-launcher": "^3.1.1",
"karma-jasmine": "^5.1.0",
"karma-spec-reporter": "0.0.34",
"postcss-loader": "^8.1.1",
"rimraf": "^2.6.1",
"source-map-loader": "^0.2.1",
"style-loader": "^3.3.1",
Expand Down
5 changes: 5 additions & 0 deletions postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
"@tailwindcss/postcss": {},
}
}
11 changes: 11 additions & 0 deletions samples/layouts/tailwind/styling/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 250,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"fluid": false
}
56 changes: 56 additions & 0 deletions samples/layouts/tailwind/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-wc-examples/tree/vnext/templates/browser/sample/ReadMe.md -->

This folder contains implementation of Web Components application with example of Styling feature using [Tailwind](https://infragistics.com/webcomponentssite/components/general-getting-started.html) component.


<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<body>
<a target="_blank" href="https://infragistics.com/webcomponentssite/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.ts" 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/webcomponents-demos/samples/layouts/tailwind/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-wc-examples/tree/master/samples/layouts/tailwind/styling?fontsize=14&hidenavigation=1&theme=dark&view=preview&file=/src/{SampleFile}" 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-angular-examples/tree/master) branch of this repository if you want to run samples on your computer. Use the [vnext](https://github.com/IgniteUI/igniteui-angular-examples/tree/vnext) branch only when you want to contribute new samples to this repository.

## Instructions

To set up this project locally, execute these commands:

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

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

In terminal window, run:

```
npm install
npm run start
```

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


## Learn More

To learn more about **Ignite UI for Web Components**, check out the [Web Components documentation](https://infragistics.com/webcomponentssite/components/general-getting-started.html).
33 changes: 33 additions & 0 deletions samples/layouts/tailwind/styling/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<title>Tailwind Styling</title>
<meta charset="UTF-8" />

<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css" type="text/css" />
<link rel="stylesheet" href="./src/index.css">
</head>

<body>
<div id="root">
<main class="text-base grid surface-500 px-6 py-6">
<div class="font-ig place-content-center text-center shadow-elevation-8 py-8">
<p class="type-style-body-1 text-primary-600">404</p>
<h1 class="type-style-h1 text-gray-900">Page not found</h1>
<p class="type-style-body-1 text-gray-500">Sorry, we couldn’t find the page you’re looking for.</p>
<div class="mt-10 flex items-center justify-center gap-x-6">
<a href="#" class="type-style-button rounded-md bg-primary-500 text-primary-500-contrast px-3.5 py-2.5 shadow-elevation-2 hover:bg-primary-600 transition duration-150 ease-in-out">Go back home</a>
<a href="#" class="type-style-button text-gray-900 hover:text-primary-600 transition duration-150 ease-in-out">Contact support <span aria-hidden="true">&rarr;</span></a>
</div>
</div>
</main>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>

</body>
</html>
67 changes: 67 additions & 0 deletions samples/layouts/tailwind/styling/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "wc-tabs-overview",
"version": "1.0.0",
"description": "This project provides example of Tabs overview using IgniteUI for Web Components",
"main": "src/index.ts",
"scripts": {
"build": "npm run build:prod",
"build:dev": "webpack --mode development --config ./webpack.config.js --progress --color --display-error-details",
"build:prod": "webpack --env.NODE_ENV=production --mode production --config ./webpack.config.js --progress --color --display-error-details --bail",
"serve:dev": "node --max-old-space-size=8192 node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode development --config ./webpack.config.js --hot --progress --open",
"serve:prod": "webpack-dev-server --env.NODE_ENV=production --mode production --config ./webpack.config.js --port 3000 --host 0.0.0.0 --hot --progress --open --content-base dist/",
"start": "npm run serve:dev",
"build:legacy": "npm run build:prod:legacy",
"build:dev:legacy": "webpack --env.legacy=true --mode development --config ./webpack.config.js --progress --color --display-error-details",
"build:prod:legacy": "webpack --env.NODE_ENV=production --env.legacy=true --mode production --config ./webpack.config.js --progress --color --display-error-details --bail",
"serve:dev:legacy": "node --max-old-space-size=8192 node_modules/webpack-dev-server/bin/webpack-dev-server.js --env.legacy=true --mode development --config ./webpack.config.js --hot --progress --open",
"serve:prod:legacy": "webpack-dev-server --env.NODE_ENV=production --env.legacy=true --mode production --config ./webpack.config.js --port 3000 --host 0.0.0.0 --hot --progress --open --content-base dist/",
"start:legacy": "npm run serve:dev:legacy"
},
"author": "Infragistics",
"dependencies": {
"@webcomponents/custom-elements": "^1.4.1",
"@webcomponents/template": "^1.4.2",
"babel-runtime": "^6.26.0",
"core-js": "^3.6.5",
"igniteui-theming": "19.1.1",
"igniteui-webcomponents": "6.1.0",
"lit": "^3.2.0",
"lit-html": "^3.2.0",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.11",
"tslib": "^2.0.0"
},
"devDependencies": {
"@babel/cli": "^7.8.3",
"@babel/core": "^7.8.3",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.10.0",
"@babel/preset-env": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@tailwindcss/postcss": "^4.1.11",
"@types/source-map": "^0.5.7",
"autoprefixer": "^10.4.21",
"babel-loader": "^8.1.0",
"babel-plugin-transform-custom-element-classes": "^0.1.0",
"css-loader": "^1.0.0",
"csv-loader": "^3.0.2",
"file-loader": "^4.2.0",
"fork-ts-checker-webpack-plugin": "^4.1.5",
"html-webpack-plugin": "^4.3.0",
"install": "^0.13.0",
"npm": "^11.4.2",
"parcel-bundler": "^1.6.1",
"postcss-loader": "^8.1.1",
"source-map": "^0.7.3",
"style-loader": "^0.22.1",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"typescript": "^4.4.4",
"webpack": "^5.96.1",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1",
"worker-loader": "^3.0.8",
"xml-loader": "^1.2.1"
},
"license": "",
"homepage": "."
}
5 changes: 5 additions & 0 deletions samples/layouts/tailwind/styling/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
"@tailwindcss/postcss": {},
}
}
7 changes: 7 additions & 0 deletions samples/layouts/tailwind/styling/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"infiniteLoopProtection": false,
"hardReloadOnChange": false,
"view": "browser",
"template": "parcel"
}

11 changes: 11 additions & 0 deletions samples/layouts/tailwind/styling/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
@import "tailwindcss";
@import "igniteui-theming/tailwind/theme";
@import "igniteui-theming/tailwind/presets/bootstrap-light";

main {
width: 800px;
height: 300px;
margin: 50px auto;
}
7 changes: 7 additions & 0 deletions samples/layouts/tailwind/styling/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import './index.css';

export class TailwindStyling {
constructor() {}
}

new TailwindStyling();
20 changes: 20 additions & 0 deletions samples/layouts/tailwind/styling/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"noImplicitReturns": true,
"esModuleInterop": true,
"noImplicitAny": true,
"declarationDir": "dist/types",
"moduleResolution": "node",
"declaration": true,
"target": "es2015",
"module": "es2015",
"strict": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
116 changes: 116 additions & 0 deletions samples/layouts/tailwind/styling/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const path = require('path');
const webpack = require('webpack');

module.exports = env => {
const nodeEnv = process.env.NODE_ENV || 'development';
const isProd = nodeEnv === 'production';
const isLegacy = !!process.env.legacy && !(process.env.legacy == "false");
console.log(">> webpack nodeEnv=" + nodeEnv);
console.log(">> webpack isProd=" + isProd);
console.log(">> webpack isLegacy=" + isLegacy);
const presets = [
["@babel/preset-env", {
"useBuiltIns": "usage",
"corejs": 3,
"targets": {
"browsers": isLegacy ? ["defaults"] : [
"last 2 Chrome versions",
"last 2 Safari versions",
"last 2 iOS versions",
"last 2 Firefox versions",
"last 2 Edge versions"]
}
}],
"@babel/preset-typescript"
];

return {
entry: isLegacy ? [
path.resolve(__dirname, 'node_modules/@webcomponents/custom-elements'),
path.resolve(__dirname, 'node_modules/@webcomponents/template'),
path.resolve(__dirname, 'src')
] : path.resolve(__dirname, 'src'),
devtool: isProd ? false : 'source-map',
output: {
filename: isProd ? '[fullhash].bundle.js' : '[fullhash].bundle.js',
globalObject: 'this',
path: path.resolve(__dirname, 'dist'),
},

resolve: {
mainFields: ['esm2015', 'module', 'main'],
extensions: ['.ts', '.js', '.json'],
plugins: [new TsconfigPathsPlugin({
configFile: './tsconfig.json',
extensions: ['.ts', '.js'],
mainFields: ['esm2015', 'module', 'main']
})]
},

module: {
rules: [
{ test: /\.(png|svg|jpg|gif)$/, use: ['file-loader'] },
{ test: /\.(csv|tsv)$/, use: ['csv-loader'] },
{ test: /\.xml$/, use: ['xml-loader'] },
{
test: /\.css$/,
sideEffects: true,
use: [
'style-loader',
{
loader: 'css-loader',
options: { importLoaders: 1 }
},
'postcss-loader'
]
},
{
test: /worker\.(ts|js)$/,
use: [
{ loader: 'worker-loader' },
{
loader: 'babel-loader', options: {
"compact": isProd ? true : false,
"presets": presets,
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
}
}
]
},
{
test: /\.(ts|js)$/, loader: 'babel-loader',
options: {
"compact": isProd ? true : false,
"presets": presets,
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
},
exclude:
function (modulePath) {
return /node_modules/.test(modulePath) &&
!/igniteui-webcomponents/.test(modulePath) &&
!/lit-html/.test(modulePath);
}
}],
},

plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(nodeEnv)
}),
new HtmlWebpackPlugin({
title: 'for-cs',
template: 'index.html'
}),
new ForkTsCheckerWebpackPlugin()
]
};
};
Loading