Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing responsive CSS columns #5

Merged
merged 5 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $html = $doc->saveHTML();
```php
$scss = new ScssCompiler();
$converter = new Compiler($scss);
$html = $converter->convertHtml(html);
$html = $converter->compileHtml(<MY HTML STRING>);
```

### Use Custom Scss
Expand All @@ -58,7 +58,7 @@ $scss = new ScssCompiler();
$scss->setScssFile(<PATH TO YOUR CUSTOM SCSS FILE);
$scss->setScssHeadFile(<PATH TO YOUR CUSTOM HEAD SCSS FILE);
$converter = new Compiler($scss);
$html = $converter->convertHtml(html);
$html = $converter->compileHtml(<MY HTML STRING>);
```

## Run Unit-Tests
Expand Down
4 changes: 2 additions & 2 deletions src/Converter/HeadStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function convert(\DOMDocument $doc)
preg_match_all('/(\.[\w\-]*).*?((,+?)|{+?)/', $customCssGroup, $customCssSelector);
$foundOccurence = false;
foreach($customCssSelector[1] as $cssSelector) {
if(count($xPath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' my-class ')]")) > 0) {
if(count($xPath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' " . trim($cssSelector, '.') . " ')]")) > 0) {
$foundOccurence = true;
}
}
Expand All @@ -32,7 +32,7 @@ public function convert(\DOMDocument $doc)
}
}

$css = preg_replace('/\n\s*\n+/', '\n', $defaultCss . $customCss);
$css = preg_replace('/\n\s*\n+/', "\n", $defaultCss . $customCss);

$html = '<html><head><style type="text/css">'.$css.'</style></head><body></body></html>';
$doc2 = new \DOMDocument('1.0', 'UTF-8');
Expand Down
15 changes: 13 additions & 2 deletions tests/resources/output/alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
.w-full, .w-full > tbody > tr > td {
width: 100% !important;
}
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
.s-5 > tbody > tr > td {
font-size: 20px !important;
line-height: 20px !important;
height: 20px !important;
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/align.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
15 changes: 13 additions & 2 deletions tests/resources/output/badge.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
.w-full, .w-full > tbody > tr > td {
width: 100% !important;
}
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
.s-5 > tbody > tr > td {
font-size: 20px !important;
line-height: 20px !important;
height: 20px !important;
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/border-radius.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/color.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/container-fluid.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
16 changes: 14 additions & 2 deletions tests/resources/output/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,23 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
.d-lg-inline {
display: unset !important;
}
.d-lg-none {
display: unset !important;
}
.d-none {
display: none !important;
}
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
34 changes: 32 additions & 2 deletions tests/resources/output/grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,41 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
.row-responsive.row {
margin-right: 0 !important;
}
td.col-lg-1 {
display: block;
width: 100% !important;
padding-left: 0 !important;
padding-right: 0 !important;
}
td.col-lg-2 {
display: block;
width: 100% !important;
padding-left: 0 !important;
padding-right: 0 !important;
}
td.col-lg-3 {
display: block;
width: 100% !important;
padding-left: 0 !important;
padding-right: 0 !important;
}
td.col-lg-6 {
display: block;
width: 100% !important;
padding-left: 0 !important;
padding-right: 0 !important;
}
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
15 changes: 13 additions & 2 deletions tests/resources/output/hr.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
.w-full, .w-full > tbody > tr > td {
width: 100% !important;
}
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
.s-5 > tbody > tr > td {
font-size: 20px !important;
line-height: 20px !important;
height: 20px !important;
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
13 changes: 11 additions & 2 deletions tests/resources/output/sizing.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,20 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
.w-10, .w-10 > tbody > tr > td {
width: 40px !important;
}
.h-10, .h-10 > tbody > tr > td {
height: 40px !important;
}
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
7 changes: 5 additions & 2 deletions tests/resources/output/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
table:not([class^=s-]) td {
border-spacing: 0px;
border-collapse: collapse;
}\n@media screen and (max-width: 600px) {\n *[class*=s-lg-] > tbody > tr > td {
}
@media screen and (max-width: 600px) {
*[class*=s-lg-] > tbody > tr > td {
font-size: 0 !important;
line-height: 0 !important;
height: 0 !important;
}\n}
}
}
</style><meta name="x-apple-disable-message-reformatting"><!--Compiled with Bootstrap Email (PHP)--></head>

<body style="margin: 0; Margin: 0; padding: 0; border: 0; outline: 0; width: 100%; min-width: 100%; height: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-family: Helvetica, Arial, sans-serif; line-height: 24px; font-weight: normal; font-size: 16px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #ffffff; color: #000000;">
Expand Down
Loading
Loading