React antdesign #media query not working - css

I'm working with react ant-design and I'm using #media queries for styling but it keeps throwing the error given below
#btn {
^
Media definitions require block statements after any features
in /home/osh/WebstormProjects/ant-design-kickstart/src/styles/styles.less (line 69, column 8)
# ./src/styles/styles.less 2:14-142 21:1-42:3 22:19-147
# ./src/index.js
# multi (webpack)-dev-server/client?http://localhost:8081 (webpack)/hot/dev-server.js react-hot-loader/patch ./src/index.js
Failed to compile.
I have given the related files below
------------styles.less file---------------
#media only screen and (max-width: 768px) {
#btn {
width: 50%;
margin-top: 200px;
align-self: center;
}
Button {
width: 1000%;
marginBottom: '25px'
}
Input {
align-self: center;
width: 250px;
}
h4 {
color: #5400ff;
}
.appDashCard {
background: #fff;
padding: 10%;
/*//minHeight: 280px;*/
align-content: center;
}
}
#media only screen and (min-width: 768px) {
#btn {
width: inherit;
margin-right: 30px;
margin-left: 400px;
margin-top: 30px;
}
h4 {
color: #ff2600;
}
.appDashCard {
background: #fff;
padding: 24px;
minHeight: 280px;
}
.selectBox {
width: 100%;
}
}
----------package.json----------
{
"name": "ant-design-kickstart",
"version": "1.0.0",
"description": "An opinionated starter-kit for Ant Design",
"scripts": {
"start": "webpack-dev-server --config ./webpack.dev.js --mode development",
"build": "webpack --config ./webpack.prod.js --mode production",
"precommit": "pretty-quick --staged"
},
"author": "Madusha Prasanjith",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-plugin-import": "^1.6.7",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^0.28.11",
"file-loader": "^1.1.11",
"husky": "^0.14.3",
"less": "^3.0.1",
"less-loader": "^4.1.0",
"less-vars-to-js": "^1.2.1",
"prettier": "1.11.1",
"pretty-quick": "^1.4.1",
"react-hot-loader": "^4.0.0",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"webpack": "^4.3.0",
"webpack-cli": "^2.0.13",
"webpack-dev-server": "^3.1.5"
},
"dependencies": {
"antd": "^3.3.3",
"axios": "^0.18.0",
"media-queries": "^1.0.5",
"moment": "^2.21.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"style-loader": "^0.20.3"
}
}
-----------webpack.dev.js----------
const webpack = require("webpack");
const path = require("path");
const fs = require("fs");
const lessToJs = require("less-vars-to-js");
const themeVariables = lessToJs(
// fs.readFileSync(path.join(__dirname, "./src/styles/ant-default-vars.less"), "utf8")
fs.readFileSync(path.join(__dirname, "./src/styles/styles.less"), "utf8")
);
module.exports = {
entry: ["react-hot-loader/patch", "./src/index.js"],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: "less-loader",
options: {
sourceMap: true,
modifyVars: themeVariables,
javascriptEnabled: true
}
}
]
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 10000
}
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "bundle.js"
},
plugins: [new webpack.HotModuleReplacementPlugin()],
devServer: {
contentBase: "./dist",
hot: true
}
};

This often indicates a syntax error. Please take a look at 'Button'. It has a property called 'marginBottom', rename it to margin-bottom, please also add a semicolon after the statement (although that shouldn't make a difference). Also, you should rename 'Button' to 'button' and 'Input' to 'input'.

Related

What do I put in the content section of module exports in "tailwind.config.js"?

I can't get Tailwind to work and I think it's because my configuration file is wrong?
/** #type {import('tailwindcss').Config} */
module.exports = {
content: ["./public/index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
I installed Tailwind and used init:
https://imgur.com/nGWspSt
I filled in the "tailwind.config.js" like this:
tailwind.config.js
/** #type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/components/DropdownVue/DropdownVue.vue"], <---INCLUDED DROPDOWN FILE
theme: {
extend: {},
},
plugins: [],
};
I created an "index.css" and imported the Tailwind modules in it like this:
src/index.css
#tailwind base;
#tailwind components; <-----INCLUDED IMPORTS
#tailwind utilities;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Noto Serif", serif, Ariel, Helvetica, sans-serif;
background: #d7d7d7;
}
img {
width: 100%;
object-fit: contain;
}
#import url("https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap");
I started the build process and got an "output.css" file
https://i.imgur.com/mOKDwuc.png
that I included in my "index.html" file like this:
public/index.html
<link href="/dist/output.css" rel="stylesheet">
At this point it should have been working but it wasn't. I realized my config file was wrong so I changed it to:
/** #type {import('tailwindcss').Config} */
module.exports = {
content: ["./public/index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
but it's still not working. Do I have to run the build process again because I changed the config file?
What am I doing wrong?
EDIT:
package.json
{
"name": "stripe-payment-vue3",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^6.2.1",
"#fortawesome/free-brands-svg-icons": "^6.2.1",
"#fortawesome/free-regular-svg-icons": "^6.2.1",
"#fortawesome/free-solid-svg-icons": "^6.2.1",
"#fortawesome/vue-fontawesome": "^3.0.2",
"#headlessui/vue": "^1.7.9",
"#heroicons/vue": "^2.0.14",
"core-js": "^3.8.3",
"vue": "^3.2.13",
"vue-router": "^4.1.6",
"vuex": "^4.0.2"
},
"devDependencies": {
"#babel/core": "^7.12.16",
"#babel/eslint-parser": "^7.12.16",
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-eslint": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"autoprefixer": "^10.4.13",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.4"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "#babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}

TailwindCSS - Applied styles removed in production

[UPDATE 28-9-2021]
What I also did to eliminate other causes: Update OS packages (Centos 8), rebuilt Apache / NGINX, rebuilt NPM modules, updated and rebuilt TailwindCSS, tried default config files / json files, but all these didn't give me any result :-( I'm really stuck here
[/UPDATE]
Maybe I'm overlooking something here.
I added some basic styling to my style.css for headings:
#tailwind base;
#tailwind components;
#tailwind utilities;
#layer base {
p {
#apply text-theme-gray-lighter pb-4;
}
h1 {
#apply text-3xl py-2;
}
h2 {
#apply text-2xl py-2 border-b mb-2;
}
h3 {
#apply text-xl py-1 font-semibold text-theme-blue;
}
h4 {
#apply text-lg font-semibold;
}
h3.price {
#apply text-theme-gray;
}
.boks-bold {
#apply font-semibold p-4 px-6 text-lg m-4 my-6 mt-2 border shadow-md rounded;
}
}
This file is located at the root of my project.
This is my tailwind.config.js:
module.exports = {
variants: {
extend: {
grayscale: ['hover', 'focus'],
backgroundColor: ['checked'],
borderColor: ['checked'],
borderColor: ['focus-within'],
}
},
darkMode: 'media',
purge: ["*.jsx", "*.js", "*.php"],
plugins: [
// require('daisyui'),
// require('#tailwindcss/forms'),
require('#tailwindcss/custom-forms'),
],
daisyui: {
// styled: false,
// themes: false,
// rtl: false,
},
theme: {
customForms: theme => ({
default: {
'input, textarea, multiselect, checkbox, radio': {
borderdColor: theme('colors.gray.200'),
},
},
}),
container: {
padding: '1rem',
center: true,
},
extend: {
width: {
'full-150': '150vw',
'full-200': '200vw',
},
height: {
'18': '4.5rem',
'40rem': '40rem',
'730px': '730px',
'650px': '650px',
'1191px': '1191px',
'901px': '901px',
'722px': '722px',
'110perc': '110%',
},
maxHeight: {
'110perc': '110%',
},
zIndex: {
'-10': '-10',
},
borderWidth: {
'12': '12px',
},
colors: {
'theme-brown': '#BF8A23',
'theme-yellow': '#FAA71B',
'theme-brown-brighter': '#DDB15B',
'theme-gray': '#333333',
'theme-gray-lighter': '#444444',
'theme-blue': '#547A82',
},
minWidth: {
'0': '0',
'1/4': '25%',
'1/2': '50%',
'3/4': '75%',
'full': '100%',
},
animation: {
'scroll-rtl-slow': 'scrollbrand scroll 40s linear infinite',
},
keyframes: {
scrollbrand: {
'0%': { transform: 'translateX(0)' },
'100%': { transform: 'translateX(calc(-250px * 7))',
}
}
}
}
}
And this is my package.json:
{
"dependencies": {
"#tailwindcss/forms": "^0.3.3",
"#tailwindcss/typography": "^0.4.1",
"autoprefixer": "^10.3.1",
"daisyui": "^1.10.0",
"node-cron": "2.0.3",
"postcss": "^8.3.6",
"postcss-cli": "^8.3.1",
"tailwindcss": "^2.2.6",
"vue-tailwind": "^2.4.2"
},
"scripts": {
"build-css": "tailwindcss build -i style.css -o css/style.css",
"build": "tailwindcss style.css -o css/style.css",
"production": "cross-env NODE_ENV=production tailwindcss css/style.css -o css/style.min.css"
},
"name": "templateh.sceneryworkshop.com",
"version": "1.0.0",
"main": "tailwind.config.js",
"devDependencies": {
"#tailwindcss/custom-forms": "^0.2.1",
"cross-env": "^7.0.3",
"webpack": "^5.52.1",
"webpack-cli": "^4.8.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
To get the #apply working, I had to add -i to the command:
*"build-css": "tailwindcss build -i style.css -o css/style.css"*
But when I do the same when building production:
"production": "cross-env NODE_ENV=production tailwindcss -i css/style.css -o css/style.min.css"
The file doesn't get purged at all, so it keeps it's total size.
Anyone who has an idea what I'm doing wrong here?
Make sure to add path to your config file in your command:
"production": "cross-env NODE_ENV=production tailwindcss -c ./tailwind.config.js -i css/style.css -o css/style.min.css"

Font not selected in Angular 10

I have created my scss project in Angular and when I try to add a font, I get an error, how do I fix the problem?
style.scss:
#import "~#angular/material/theming";
#include mat-core();
$PWP-primary: mat-palette($mat-indigo);
$PWP-accent: mat-palette($mat-pink, A200, A100, A400);
$PWP-warn: mat-palette($mat-red);
$PWP-theme: mat-light-theme($PWP-primary, $PWP-accent, $PWP-warn);
#include angular-material-theme($PWP-theme);
#import "~bootstrap/dist/css/bootstrap.css";
#import './variables.scss';
html,body {
height: 100%;
}
body {
margin: 0;
font-family: $font-vazir-bold;
direction: rtl;
}
variables.scss:
$font-vazir-bold:"Vazir";
#font-face {
font-family: Vazir;
src: url("../assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
src: url("../assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
}
Inside the file (angular.json) I changed the path of the style.scss file.
angular.json:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"PWP": {
"projectType": "application",
"schematics": {
"#schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "#angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/PWP",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/scss/styles.scss",
"src/scss/mixin.scss",
"src/scss/variables.scss",
"./node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts": [
"./node_modules/bootstrap/dist/js/bootstrap.js",
"./node_modules/bootstrap/dist/js/bootstrap.js"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "#angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "PWP:build"
},
"configurations": {
"production": {
"browserTarget": "PWP:build:production"
}
}
},
"extract-i18n": {
"builder": "#angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "PWP:build"
}
},
"test": {
"builder": "#angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/scss/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "#angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "#angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "PWP:serve"
},
"configurations": {
"production": {
"devServerTarget": "PWP:serve:production"
}
}
}
}
}
},
"defaultProject": "PWP",
"cli": {
"analytics": "c792c032-9136-42b5-8b0a-391b6f8d84c5"
}
}
package.json:
{
"name": "pwp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "~9.1.7",
"#angular/cdk": "^9.2.4",
"#angular/common": "~9.1.7",
"#angular/compiler": "~9.1.7",
"#angular/core": "~9.1.7",
"#angular/forms": "~9.1.7",
"#angular/material": "^9.2.4",
"#angular/platform-browser": "~9.1.7",
"#angular/platform-browser-dynamic": "~9.1.7",
"#angular/router": "~9.1.7",
"bootstrap": "^4.6.0",
"jquery": "^3.5.1",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.901.6",
"#angular/cli": "~9.1.6",
"#angular/compiler-cli": "~9.1.7",
"#types/node": "^12.11.1",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
}
}
Error in console:
Failed to compile.
./src/app/layout/home/home.component.scss
Module Error (from ./node_modules/postcss-loader/src/index.js):
(Emitted value instead of an instance of Error) CssSyntaxError: E:\project\PwpEnd\PWP\src\scss\variables.scss:5:4: Can't resolve '../assets/font/vazir-font-v27.2.0/Vazir-Bold.eot' in 'E:\project\PwpEnd\PWP\src\app\layout\home'
3 | #font-face {
4 | font-family: Vazir;
> 5 | src: url("../assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
| ^
6 | src: url("../assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
7 | }
How do I fix this problem?
enter image description here
try this
#font-face {
font-family: Vazir;
src: url("~/assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
src: url("~/assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
}
Ans from https://github.com/angular/angular-cli/issues/6599
I have same problem ,and it work for me
The address of the photos must be given from the root, as follows
$font-vazir-bold:"Vazir";
#font-face {
font-family: Vazir;
src: url("src/assets/font/vazir-font-v27.2.0/Vazir-Bold.eot");
src: url("src/assets/font/vazir-font-v27.2.0/Vazir-Black.ttf") format("ttf");
}

GRUNT: grunt-postcss not executing cssnano when used together with sass - if scss file long

I am using both the sass parser and gruntpostcss with cssnano on watch. cssnano` is parsing the file just fine if its a short file, but it my scss/css file gets long css file, the it is not parsing the file. Anyone knows why that is and how to fix it?
Here the package.json, Gruntfile.js and both a short-css-file.css which works and a long-css-file.css where the cssnano is not parsing it.
package.json
{
"name": "testpage",
"version": "1.0.0",
"description": "testpage grunt",
"main": "Gruntfile.js",
"dependencies": {},
"devDependencies": {
"cssnano": "^3.10.0",
"grunt": "^1.0.3",
"grunt-contrib-watch": "^1.0.0",
"grunt-postcss": "^0.8.0",
"load-grunt-tasks": "^3.5.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
watch: {
css: {
files: 'wp-content/themes/mytheme/assets/css/*.scss',
tasks: ['sass', 'postcss']
},
},
sass: {
options: {
sourceMap: true
},
dist: {
files: {
'wp-content/themes/mytheme/assets/css/default.css': 'wp-content/themes/mytheme/assets/css/default.scss'
}
}
},
postcss: {
options: {
map: {
inline: false, // save all sourcemaps as separate files...
sourcesContent: true,
},
processors: [
require('autoprefixer')({browsers: ['last 2 versions', 'ie 8', 'ie 9']}), // add vendor prefixes
require('cssnano')({zindex: false}) // minify the result
]
},
dist: {
files: {
'wp-content/themes/mytheme/assets/css/default.css': 'wp-content/themes/mytheme/assets/css/default.css'
}
}
},
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['watch', 'sass', 'postcss']);
};
short-css-file.css
// Test
.css_nano, .css_nano + p, [class*="css_nano"], .css_nano {
/* cssnano will remove this comment */
display: flex;
font-weight: normal;
margin-top: 1rem;
margin-bottom: 2rem;
margin-left: 1.5rem;
margin-right: 2.5rem;
font-weight: normal;
padding: 1.75rem;
width: calc(50rem - (2 * 1.75rem));
}
long-css-file.css see in the jsfiddle
https://jsfiddle.net/12p3Lxcn/

Remove ouline on PrimeNG checkbox

I would like to remove the glow, a.k.a outline, of the PrimeNG checkbox component. (I know, I know. It's for accessability and all, but I'm implementing this indicator myself)
I've tried to set every thinkable class or selector to outline: none, and even the big bang approach with
*:focus {
outline: none !important;
}
But nothing seems to work...
What do I need to do to get rid of it?
Thanks!
Edit, My angular-cli.json:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"project": {
"name": "test"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.sass",
"../node_modules/font-awesome/css/font-awesome.min.css",
"../node_modules/primeng/resources/primeng.min.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "sass",
"class": {
"spec": false
},
"component": {}
}
}
And at the top of my styles.sass I import my primeng.scss file:
#import 'primeng'
In the omege theme.scss line 242 you will see:
.ui-chkbox-box.ui-state-focus,
.ui-radiobutton-box.ui-state-focus {
-moz-box-shadow: 0px 0px 5px #1f89ce;
-webkit-box-shadow: 0px 0px 5px #1f89ce;
box-shadow: 0px 0px 5px #1f89ce;
}
This is the style giving the checkbox the glow. You can set those properties to none to stop this.
.ui-chkbox-box.ui-state-focus,
.ui-radiobutton-box.ui-state-focus {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
If you don't want to edit the theme file you can override the css by doing something like:
.ui-chkbox-box.ui-state-focus {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
The example above also includes radio buttons. Just reformat the css to exclude it: .ui-radiobutton-box.ui-state-focus
This is what worked for me
:host ::ng-deep .p-checkbox:not(.p-checkbox-disabled) .p-checkbox-box.p-focus {
box-shadow: none;
}

Resources