Skip to content

Commit

Permalink
Merge pull request #101 from RpNation/code/rowsAndColumns
Browse files Browse the repository at this point in the history
Code/rows and columns
  • Loading branch information
Alteras1 authored Jun 27, 2024
2 parents 2e9847c + 8b2603b commit 0a5feec
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The goal of this repo and plugin is to provide users with the BBCode suite that
- [x] Scroll Box
- [ ] Div Box
- [x] Anchors
- [ ] Rows & Columns
- [x] Rows & Columns

## Media & Embeds

Expand Down
2 changes: 1 addition & 1 deletion assets/bundled/bbcode-parser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/bundled/bbcode-parser.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions assets/javascripts/lib/discourse-markdown/bbcode-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function setup(helper) {
"div.bb-border",
"div.bb-center",
"div.bb-check",
"div.bb-column",
"div.bb-email",
"div.bb-email-address",
"div.bb-email-button",
Expand Down Expand Up @@ -149,6 +150,7 @@ export function setup(helper) {
"div.bb-progress-thin",
"div.bb-ooc",
"div.bb-right",
"div.bb-row",
"div.bb-scroll",
"div.bb-side",
"div.bb-slide-content",
Expand Down
1 change: 1 addition & 0 deletions assets/stylesheets/common/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@import "pindent.scss";
@import "print.scss";
@import "progress.scss";
@import "rowcolumn.scss";
@import "scroll.scss";
@import "side.scss";
@import "size.scss";
Expand Down
62 changes: 62 additions & 0 deletions assets/stylesheets/common/rowcolumn.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.bb-row {
width: 100%;
clear: both;
margin: 0;
}

.bb-row .bb-column {
margin: 0 0.5%;
padding: 0 0.5%;
float: left;
}

.bb-column {
margin: 0 0.5%;
padding: 0 0.5%;
float: left;
&[data-span="column-width-span1"] {
width: 13.5%;
}
&[data-span="column-width-span2"] {
width: 23%;
}
&[data-span="column-width-span3"] {
width: 41%;
}
&[data-span="column-width-span4"] {
width: 48%;
}
&[data-span="column-width-span5"] {
width: 66%;
}
&[data-span="column-width-span6"] {
width: 79%;
}
&[data-span="column-width-span7"] {
width: 91%;
}
&[data-span="column-width-span8"] {
width: 100%;
}
}

@media screen and (max-width: 900px) {
.bb-row {
&[data-span="column-width-span1"],
&[data-span="column-width-span2"],
&[data-span="column-width-span3"],
&[data-span="column-width-span4"],
&[data-span="column-width-span5"],
&[data-span="column-width-span6"],
&[data-span="column-width-span7"],
&[data-span="column-width-span8"] {
width: 100%;
}

.bb-column {
margin: 0;
padding: 0;
float: none;
}
}
}
2 changes: 2 additions & 0 deletions bbcode-src/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { pindent } from "./tags/pindent";
import { plain } from "./tags/plain";
import { print } from "./tags/print";
import { progress } from "./tags/progress";
import { rowcolumn } from './tags/rowcolumn';
import { thinprogress } from "./tags/thinprogress";
import { scroll } from "./tags/scroll";
import { side } from "./tags/side";
Expand Down Expand Up @@ -86,6 +87,7 @@ const tags = {
plain,
print,
progress,
...rowcolumn,
thinprogress,
savenl,
sh,
Expand Down
16 changes: 16 additions & 0 deletions bbcode-src/tags/rowcolumn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { preprocessAttr, toNode } from "../utils/common";

/**
* @file Adds [row][column] to bbcode
* @example Adds [row][column][/column][/row]
*/
export const rowcolumn = {
row: (node) => toNode("div", { class: "bb-row" }, node.content),
column: (node) => {
const columnAttrs = preprocessAttr(node.attrs)._default || "8";
const columnStyle = columnAttrs.startsWith("span")
? `column-width-${columnAttrs}`
: `column-width-span${columnAttrs}`;
return toNode("div", { class: `bb-column`, "data-span": columnStyle }, node.content);
},
};

0 comments on commit 0a5feec

Please sign in to comment.