svelte with sass and tailwind apply semicolon expected - sass

In my svelte project I am using tailwind and sass for styling. But It is resulting an error
[!] (plugin svelte) ParseError: Semicolon or block is expected
[0] src/App.svelte
[0] 10368: #tailwind components;
[0] 10369: h1 {
[0] 10370: #apply text-black bg-white !important;
[0] ^
[0] 10371: }</style>
according to tailwind docs I am using #{!important} instead of !important in style tag.
App.svelte
<script lang="ts">
</script>
<main>
<style>
</style>
<h1 class="is-size-1 text-white">Hello World!</h1>
<p>
Visit the Svelte tutorial to learn
how to build Svelte apps.
</p>
</main>
<style lang="scss">
#import "bulma/bulma.sass";
#import "tailwindcss/utilities";
#import "tailwindcss/base";
#import "tailwindcss/components";
h1 {
#apply text-black bg-white #{!important};
}
</style>
I am not understanding why this error is occuring.

Related

Using SCSS scoped in Blade like Vue components

I'm using Laravel 8 and Vue.js together. So I'm developing a website with Blade and Vue components.
I want something to add scss code in a specific Blade template. Exactly like a Vue component:
// Vue component example
<template>
...
</template>
<script>
...
</script>
<style lang="scss" scoped>
// SCSS codes scoped here
</style>
I want something exactly like <style lang="scss" scoped> in Blade.
Thank you.
you can use blade #stack and #push
in layout.blade.php
#stack('css')
in specific.blade.php
#push('css')
<style>
</style>
#endpush
like this when specific.blade.php will load then only that css will load in layout which is same as vue scoped
ref link
https://laravel.com/docs/8.x/blade#stacks
I have been in a simular situation. I'm not aware of this being possible without a lot of work (on the blade compiler side). Having <style lang="scss" scoped> in blade would require scss compilation and scoping. A simpler solution would be as Kamlesh suggested, supplying the style in the template.
Something that does come close as well albeit without scss compilation is having the ability to write multiple vue single file component-like components in your blade templates. Vue does not provide this ability (as elegantly as with vue files imho), but with a layer called vue blocks you may achieve the following:
<template component="some-component">
<div>
<p>My paragraph</p>
<div class="some block"></div>
</div>
<style scoped>
:root {
background: black;
padding: 20px;
margin: 20px;
}
p {
color: red;
font-weight: bold;
}
.block {
border: 3px solid green;
height: 20px;
}
</style>
<script>
// vue component here
export default {
data() { return { } },
mounted() {
}
}
</script>
</template>
More information can be found here:
https://fluxfx.nl/vue-blocks/examples/index.html#/features/scoped-styles

With html2pdf in generated pdf as all css styles are lost

In my laravel 5.7 / bootstrap 4.4 app I use
spatie/browsershot 3.37 and spipu/html2pdf 5.2 to generate pdf file
and for my generated pdf file want I set layout with 100% height and footer and
header like here: https://jsfiddle.net/MadLittleMods/LmYay/
But imported block of code which looks ok on my blade page in browser is invalid in generated
pdf : as all css styles are lost.
by clicking on “To pdf file” content of the page is rendered into pdf file:
Browsershot::html(htmlspecialchars_decode($pdf_content))
->showBackground()
->save($save_to_file);
if($hidden_action== 'upload') {
\Response::download($save_to_file, $filename_to_save, array('Content-Type: application/octet-stream', 'Content-Length: pdf'));
return response()->download($save_to_file, $filename_to_save)->deleteFileAfterSend(true);
}
in my blade file:
#extends($current_admin_template.'.layouts.backend')
#section('content')
#inject('viewFuncs', 'App\library\viewFuncs')
<div id="page-wrapper" class="card">
// THIS PART LOOKS OK IN BROWSER BUT IN GENERATED PDF INVALID AS ALL CSS CLASSES ARE LOST
<div class="flexbox-parent" id="div_invoice_content" style="display: flex;">
<input type="hidden" id="hidden_invoice_no" name="hidden_invoice_no" value="{{$invoice_no}}">
<input type="hidden" id="hidden_invoice_id" name="hidden_invoice_id" value="{{$invoice_id}}">
<div class="flexbox-item header">
Header $invoice_no::{{$invoice_no}}<br>
$invoice_id::{{$invoice_id}}
</div>
<div class="flexbox-item fill-area content flexbox-item-grow">
<div class="fill-area-content flexbox-item-grow">
Content
<br /><br />
Emulates height 100% with a horizontal flexbox with stretch
<br /><br />
This box with a border should fill the blue area except for the padding (just to show the middle flexbox item).
</div>
</div>
<div class="flexbox-item footer">
Footer
</div>
</div>
<form method="POST" action="{{ url('/admin/generate-pdf-by-content') }}" accept-charset="UTF-8" id="form_print_to_pdf_content"
name="form_print_to_pdf_content"
enctype="multipart/form-data">
{!! csrf_field() !!}
<div class="form-row m-3">
...
FORM CONTENT
...
</div>
</section> <!-- class="card-body" -->
</div>
<!-- /.page-wrapper page Content : invoice edit -->
#endsection
{{--#section('head')--}}
{{--#push('scripts')--}}
<style lang="css">
.flexbox-parent
{
height: 842pt !important;
width: 595pt !important;
display: flex;
flex-direction: column;
justify-content: flex-start; /* align items in Main Axis */
align-items: stretch; /* align items in Cross Axis */
align-content: stretch; /* Extra space in Cross Axis */
background: rgba(255, 255, 255, .1);
}
.flexbox-item
{
padding: 8px;
}
.flexbox-item-grow
{
flex: 1; /* same as flex: 1 1 auto; */
}
.flexbox-item.header
{
background: rgba(255, 0, 0, .1);
}
.flexbox-item.footer
{
background: rgba(0, 255, 0, .1);
}
.flexbox-item.content
{
background: rgba(0, 0, 255, .1);
}
.fill-area
{
display: flex;
flex-direction: row;
justify-content: flex-start; /* align items in Main Axis */
align-items: stretch; /* align items in Cross Axis */
align-content: stretch; /* Extra space in Cross Axis */
}
.fill-area-content
{
background: rgba(0, 0, 0, .3);
border: 1px solid #000000;
/* Needed for when the area gets squished too far and there is content that can't be displayed */
overflow: auto;
}
</style>
{{--#endpush--}}
{{--#endsection--}}
#section('scripts')
<link rel="stylesheet" href="{{ asset('/css/gijgo.min.css') }}" type="text/css">
<script src="{{ asset('js/AutoNumeric/autonumeric#4.1.0') }}"></script>
...
#endsection
I tried to put <style block in several places of the page, but in all cases
in generated pdf as all css styles are lost
Which is valid way to use css classes in the generated file?
MODIFIED BLOCK 1:
I created file public/css/flb_layout.css with all flexbox classes definitions and
in my blade file I added asset to this css file:
#section('scripts')
<link rel="stylesheet" href="{{ asset('/css/gijgo.min.css') }}" type="text/css">
<link rel="stylesheet" href="{{ asset('/css/flb_layout.css') }}" type="text/css">
...
and checking source of generated html file I see link to flb_layout.css file:
</footer>
<link rel="stylesheet" href="http://local-boxbooking2.com/css/gijgo.min.css" type="text/css">
<link rel="stylesheet" href="http://local-boxbooking2.com/css/flb_layout.css" type="text/css">
where http://local-boxbooking2.com - is hosting of my local app.
and as result in my browser I see that flexbox layout is rendered ok,
but generating pdf file I see plain html without flexbox classes definitions applied.
Which way is valid ?
MODIFIED BLOCK 2:
I found a hint:
The asset function generates a URL for an asset using the current
scheme of the request (HTTP or HTTPS)
The library you're using launches a puppeteer instance in the
background to capture the PDF.
Instead of generating a URL, try generating an absolute path to the
file on your machine: (obviously you can leave out the mix helper if
you do not use Laravel Mix)
> <link rel="stylesheet" href="{{
> public_path(mix('/path/to/styles.css')) }}" />
So in my blade form I chanhed refering to my css :
<link rel="stylesheet" href="{{ public_path('/css/flb_layout.css') }}">
As result my css classes are not rendered in the page of the browser.
In generated pdf file my css classes are not rendered too.
In my project I use webpack.mix.js with definitions:
const mix = require('laravel-mix');
let current_admin_template= 'Backend';
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/' + current_admin_template + '/backend.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/' + current_admin_template + '/style_lg.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/' + current_admin_template + '/style_md.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/' + current_admin_template + '/style_sm.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/' + current_admin_template + '/style_xs_320.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/' + current_admin_template + '/style_xs_480.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/' + current_admin_template + '/style_xs_600.scss', 'public/css/' + current_admin_template)
.sass('resources/sass/debug.scss', 'public/css' )
;
Can it be used anyway?
Thanks!
It does not work like that in pdf Parser plugin.. give all css inline. NOTE: no files can be read directly.
I failed to add css classes to spipu/html2pdf and had to move into https://github.com/spatie/browsershot
with style definition :
Browsershot::url('https://example.com')
->setOption('addStyleTag', json_encode(['content' => 'body{ font-size: 14px; }']))
->save($pathToImage);
which works ok for me...

Modify css of text field or select in vuetify components [duplicate]

This question already has an answer here:
Vuetify - CSS not working (taking effect) inside component
(1 answer)
Closed 4 years ago.
I am trying to modify the css of the vuetify components for example change the font-size to 10px, but it does not take my class into account
Is there a solution for this ?
I'm gonna assume you are using one of the pre-processors out there (SASS or Stylus).
So the thing is that you probably have the style section scoped for example <style lang="scss" scoped>.
What you want to do, is to use the deep selector so the styles from your parent component will leak into the child component, in this case vuetify component.
That can be achieved in sass like so:
<template>
<div class="button-wrapper">
<v-btn color="success">Success</v-btn>
</div>
<template>
And then in the style tag:
<style lang="scss" scoped>
.button-wrapper /deep/ button{
background: #00e389;
color: #fff;
}
</style>
Note: I do not use Stylus but if I'm not mistaken the syntax for deep is >>> so in this case, it will be .button-wrapper >>> button. you can read more about it here in the vue-loader docs
You could add this to your component:
<!-- in your component -->
<template>
<p class="change-font">Changing font</p>
</template>
<script>
export default {
};
</script>
<style lang="css" scoped>
.change-font{
font-size: 10px;
}
</style>
If you are using stylus, scss, or something else, change lang="css" to lang="stylus" or lang="scss"
Hope this helps.
If you are using stylus, you can do it :
<style lang="stylus" scoped>
.wrapper >>> button
font-size 10px
</style>

SCSS variable is not working

I found myself with a problem. When I was using css I had no problem setting the properties of the html elements with css, but I'm now trying to use scss and, for some reason that I'm unaware of, I can´t change the properties using the scss variables.
I'd be thankful if anyone could give me a solution for this issue.
HTML
<html>
<head>
</head>
<body>
<div id="example"></div>
</body>
</html>
SCSS
$color-1 : #202020;
#example {
background-color: $color-1;
width: 200px;
height: 100px;
}

Dart Polymer: Creating PaperDialog with CoreAnimatedPages displayed incorrectly in Firefox

I use Dart Polymer PaperDialogs containing CoreAnimatedPages. The idea is to have popups in which you can click through multiple option views.
Example repository available at: https://bitbucket.org/neogucky/polymer-dialog-problem/
DialogView: view.html
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="packages/paper_elements/paper_button.html">
<link rel="import" href="packages/paper_elements/paper_dialog.html">
<link rel="import" href="packages/paper_elements/paper_dialog_transition.html">
<link rel="import" href="packages/core_elements/core_animated_pages.html">
<polymer-element name="test-view">
<template>
<paper-dialog id="extendedNode" vertical autoCloseDisabled=true transition="paper-transition-center" opened=true class="noTitle">
<content>
<core-animated-pages selected="{{page}}" valueattr="id" transitions="hero-transition cross-fade">
<section id="0">
<br><br>
<p cross-fade>Click next to see the secret text.</p>
</section>
<section id="1">
<br><br>
<p cross-fade >This text is a secret, so don't tell Firefox users!</p>
</section>
</core-animated-pages>
</content>
</paper-dialog>
</template>
<script type="application/dart" src="view.dart"></script>
</polymer-element>
CSS-file:
html /deep/ paper-dialog {
margin-top: -150px;
margin-left: -300px;
}
html /deep/ paper-dialog /deep/ core-animated-pages{
height: 300px;
width: 600px;
}
Expected behavior: Upon page load a 300px x 600px dialog should popup with a button at the bottom left.
Behavior in Firefox: A small dialog is shown and resembles the dialog in chrome when there is no size set in the css file.
I would like to confirm if this is my fault for using incorrect CSS hooks or if this seems to be a polymer problem with Firefox.
If you CSS is not inside a Polymer element you need to add the polyfill version of the selectors to make it work on browsers without native shadow-DOM support
html paper-dialog,
html /deep/ paper-dialog {
margin-top: -150px;
margin-left: -300px;
}
html paper-dialog core-animated-pages,
html /deep/ paper-dialog /deep/ core-animated-pages{
height: 300px;
width: 600px;
}
See https://www.polymer-project.org/0.5/docs/polymer/styling.html and https://www.polymer-project.org/0.5/articles/styling-elements.html for more details

Resources