Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…s-faweb-demo into 4-style-buttons
  • Loading branch information
kesiah committed Dec 6, 2024
2 parents 17bfdd4 + 8efd36e commit 04a69b8
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"extends": ["stylelint-config-standard"],
"rules": {
"selector-class-pattern": [
"^[a-z]([-]?[a-z0-9]+)*(__[a-z0-9]([-]?[a-z0-9]+)*)?(--[a-z0-9]([-|_]?[a-z0-9]+)*)?$",
{
"message": "Expected class \"%s\" to be in kebab-case or BEM-style naming."
}
],
"media-feature-range-notation": "prefix"
}
}
46 changes: 46 additions & 0 deletions blocks/text-image/text-image.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.text-image__container {
--image-width: 50%;

display: flex;
flex-direction: column;
gap: 24px;

@media (min-width: 768px) {
flex-direction: row;
}

.text-image--h-center & {
text-align: center;
}

.text-image--v-center & {
align-items: center;
}

> div:not(.text-image__image-container) {
order: 1;
flex-grow: 1;

@media (min-width: 768px) {
order: initial;
width: calc(100% - var(--image-width));
}
}
}

.text-image__image-container {
order: 0;

@media (min-width: 768px) {
order: initial;
width: var(--image-width);

.text-image--bigimage & {
--image-width: 70%;
}

.text-image--smallimage & {
--image-width: 30%;
}
}
}
13 changes: 13 additions & 0 deletions blocks/text-image/text-image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { variantsClassesToBEM } from '../../scripts/common.js';

const variantClasses = ['bigimage', 'smallimage', 'v-center', 'h-center'];

export default function decorate(block) {
const blockName = 'text-image';
// add variant classnames
variantsClassesToBEM(block.classList, variantClasses, blockName);

block.firstElementChild.classList.add(`${blockName}__container`);
const pictureParent = block.querySelector('picture').parentElement;
pictureParent?.classList.add(`${blockName}__image-container`);
}

0 comments on commit 04a69b8

Please sign in to comment.