Skip to content

Instantly share code, notes, and snippets.

@fstbraz
Created August 30, 2022 21:15
Show Gist options
  • Save fstbraz/7979c4f5bc3ae07e5ed100cadd1c7b35 to your computer and use it in GitHub Desktop.
Save fstbraz/7979c4f5bc3ae07e5ed100cadd1c7b35 to your computer and use it in GitHub Desktop.
cross-framework-web-components-3
...
import { sharedStyles } from './shared/style';
const componentStyle = css`
h2 {
margin-bottom: 1rem;
}
.card + .card {
margin-top: 1.5rem;
}
@supports (display: grid) {
.card + .card {
margin-top: 0;
}
}
.card {
cursor: pointer;
border: 1px solid;
border-radius: 0.25rem;
display: flex;
flex-direction: column;
position: relative;
}
.card .text {
padding: 1rem;
flex: 1 0 auto;
display: flex;
flex-direction: column;
cursor: pointer;
}
.card p {
max-width: 60ch;
}
.card .img {
height: 6.5rem;
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - 1rem));
}
.card .img img {
width: 100%;
height: 100%;
object-fit: cover;
filter: grayscale(100%);
}
.card a {
outline: none;
}
.card h2 a {
text-decoration: none;
}
.card h2 a:focus {
text-decoration: underline;
}
.card h2:focus-within ~ .cta {
box-shadow: 0 0 0 0.125rem;
}
.card:focus-within h2 a:focus {
text-decoration: none;
}
.card small {
display: block;
text-align: right;
}
.card small a {
position: relative;
text-decoration: none;
padding: 0.5rem 0;
}
.card small a:hover,
.card small a:focus {
text-decoration: underline;
}
.card .text > * + * {
margin-top: 0.75rem;
}
.card .text > :nth-last-child(3) {
margin-bottom: 0.75rem;
}
.card .text > :nth-last-child(2) {
margin-top: auto;
padding-top: 0.75rem;
}
.cta {
padding: 0.75rem;
border: 1px solid;
border-radius: 0.25rem;
text-align: center;
}
.cta > a {
text-decoration: none;
}
`;
@customElement('card-image')
export class Card extends LitElement {
static styles = [sharedStyles, componentStyle];
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment