Skip to content

Commit

Permalink
feat: extend widget with optional single column layout (#296)
Browse files Browse the repository at this point in the history
* Add optional single column layout to widget

Co-authored-by: Adrian Santana Berg <adriansberg@users.noreply.github.com>

* include comments.

* extend logic to use andIf() to set css classes.

Co-authored-by: Adrian Santana Berg <adriansberg@users.noreply.github.com>

* Include single column option in script documentation.

---------

Co-authored-by: Adrian Santana Berg <adriansberg@users.noreply.github.com>
  • Loading branch information
jonasbrunvoll and adriansberg authored May 31, 2024
1 parent e44df5e commit 1ef2c6b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/pages/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const initializeCode = html`
// Inherit font from page website.
// By default it uses Roboto as the hosted planner web solution.
inheritFont: false,
// Use single column design of widget layout
singleColumnLayout: false,
},
});
Expand Down Expand Up @@ -204,8 +206,12 @@ function WidgetContent({

<ul style={{ listStylePosition: 'inside', marginTop: '1rem' }}>
<li>
<code>.widget-inheritFont</code>: Inherit font family from the
website
<code>.widget-module__inheritFont</code>: Inherit font family from
the website
</li>
<li>
<code>.widget-module__singleColumnLayout</code>: Use single column
design of widget layout
</li>
</ul>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/widget/widget.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,24 @@
.messageBox[hidden] {
display: none;
}

/**
* Configurable options for widget
*/

/* Inherit the font from the web page using the widget. */
.inheritFont,
.inheritFont * {
font-family: inherit !important;
}

/* Change the layout to a single column layout instead of the default layout. */
.singleColumnLayout .main {
grid-template-columns: 1fr;
}
.singleColumnLayout .search_container {
max-width: unset;
}
.singleColumnLayout .selector_options {
width: 100%;
}
13 changes: 10 additions & 3 deletions src/widget/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { SearchTime } from '@atb/modules/search-time/types';
import Combobox from '@github/combobox-nav';

import style from './widget.module.css';
import { andIf } from '../utils/css';

const DEFAULT_DEBOUNCE_TIME = 300;

Expand Down Expand Up @@ -41,6 +42,7 @@ function createSettingsConstants(urlBase: string) {

type OutputOverrideOptions = {
inheritFont?: boolean;
singleColumnLayout?: boolean;
};
export type WidgetOptions = {
urlBase: string;
Expand All @@ -62,6 +64,7 @@ export function createWidget({

const defaultOutputOverrideOptions: OutputOverrideOptions = {
inheritFont: false,
singleColumnLayout: false,
...outputOverrideOptions,
};

Expand Down Expand Up @@ -721,9 +724,13 @@ function createOutput(

const output = html`
<div
class="${style.wrapper} ${style.lightWrapper} ${outputOverrideOptions.inheritFont
? style.inheritFont
: ''}"
class="${andIf({
[style.wrapper]: true,
[style.lightWrapper]: true,
[style.inheritFont]: outputOverrideOptions.inheritFont ?? false,
[style.singleColumnLayout]:
outputOverrideOptions.singleColumnLayout ?? false,
})}"
>
<nav class="${style.nav}">
<ul class="${style.tabs} js-tablist">
Expand Down

0 comments on commit 1ef2c6b

Please sign in to comment.