Skip to content

Commit

Permalink
Add rtl option
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Mar 14, 2021
1 parent f5dbea8 commit 2fc1bbb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ The first three are column based and work similarly:

All column based layouts accept the following options:

|Option|Values|Description|Default
|Option|Values|Description|Default|
|---|---|---|---|
|`width`| number | Size in pixels of each column | 300 |
|`max_width` | number | Maximum width of a card | 1.5 * `width` if specified <br> otherwise 500 |
|`max_cols` | number | Maximum number of columns to show | 4 if sidebar is hidden <br> 3 if sidebar is shown |
|`rtl`| `true`/`false` | Place columns in right-to-left order | `false`|

### Masonry layout

Expand Down
4 changes: 2 additions & 2 deletions layout-card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/layouts/base-column-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BaseLayout } from "./base-layout";

export class BaseColumnLayout extends BaseLayout {
@property() _columns?: number;
@property() _config: ColumnViewConfig;

_observer?: ResizeObserver;
_mediaQueries: Array<MediaQueryList | null> = [];
Expand Down Expand Up @@ -151,6 +152,9 @@ export class BaseColumnLayout extends BaseLayout {
);

cols = cols.filter((c) => c.childElementCount > 0);
if (this._config.layout?.rtl) {
cols.reverse();
}

const columns = this.shadowRoot.querySelector("#columns");
while (columns.firstChild) columns.removeChild(columns.firstChild);
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ViewConfig {
title?: string;
type?: string;
cards?: Array<CardConfig>;
layout?: any;
layout?: {};
}

export interface ColumnViewConfig extends ViewConfig {
Expand All @@ -38,6 +38,7 @@ export interface ColumnViewConfig extends ViewConfig {
max_width?: number;
max_cols?: number;
min_height?: number;
rtl?: boolean;
};
}

Expand Down

0 comments on commit 2fc1bbb

Please sign in to comment.