I'm using javascript and lit-element.
I've a web component called "my-list" that has inside some div with text, and another web component (called "my-table"), that is a table showing a list of items with different features. Inside "my-table" I've written some css and some functions that do some things with data inside the table (for ex: sorting).
What I want to do is to print the webpage related to "my-list" component, changing the layout of the table (for ex: reduce the padding, or delete the table border, or change the font-color, and similar stuffs).
I tried with @media print inside "my-list", for example with:
static get styles () {
return [
super.styles,
css`
@media print {
my-table {
color: red;
}
}
`
];
}
Obviously, the font color of items in my-table doesn't change if I try to print the webpage.
Does it exist a way to change css of custm web component inside another web component?
I thought to 2 different solutions:
create another web component "myTable-printVersion" with the right css that I want for print, define it inside "my-list", set "visibility: hidden" if I don't print the page and "visibility: visible" inside @media print.
modify the css for print directly inside a @media print defined in "my-table". This is not my favorite solution because I use "my-table" component inside other components, and I dont' want the same print layout for each of these components. For example, I want different font color for each of these components when I print them. Red for "my-list", blue for "myOther-list".
Thanks for your help!