Skip to content

Commit

Permalink
[#140] introduced ConstructibleStyleSheets utility class allowing to …
Browse files Browse the repository at this point in the history
…centralize usages of reusable sass stylesheets
  • Loading branch information
fcamblor committed May 4, 2021
1 parent ff2295f commit 3aeda9f
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 31 deletions.
5 changes: 2 additions & 3 deletions src/components/vmd-appointment-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import {
import {Router} from "../routing/Router";
import {Dates} from "../utils/Dates";
import appointmentCardCss from "./vmd-appointment-card.component.scss";
import globalCss from "../styles/global.scss";
import {Strings} from "../utils/Strings";
import {TemplateResult} from "lit-html";
import {styleMap} from "lit-html/directives/style-map";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

type LieuCliqueContext = {lieu: Lieu};
export type LieuCliqueCustomEvent = CustomEvent<LieuCliqueContext>;
Expand All @@ -24,7 +23,7 @@ export class VmdAppointmentCardComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`${unsafeCSS(appointmentCardCss)}`,
css`
`
Expand Down
4 changes: 2 additions & 2 deletions src/components/vmd-appointment-metadata.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LitElement, html, customElement, property, css, unsafeCSS} from 'lit-element';
import {classMap} from "lit-html/directives/class-map";
import globalCss from "../styles/global.scss";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

export type MetadataWidthType = 'full-width'|'fit-to-content'|'3col-equally-distributed'
const METADATA_WIDTH_CLASSES: {[type in MetadataWidthType]: string} = {
Expand All @@ -15,7 +15,7 @@ export class VmdAppointmentMetadataComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`
`
];
Expand Down
4 changes: 2 additions & 2 deletions src/components/vmd-button-switch.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {css, customElement, html, LitElement, property, unsafeCSS} from "lit-element";
import globalCss from "../styles/global.scss";
import buttonSwitchCss from "./vmd-button-switch.component.scss";
import {repeat} from "lit-html/directives/repeat";
import {classMap} from "lit-html/directives/class-map";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

export type ValueStrCustomEvent<T extends string> = CustomEvent<{value: T}>;

Expand All @@ -16,7 +16,7 @@ export class VmdButtonSwitchComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`${unsafeCSS(buttonSwitchCss)}`,
css`
:host {
Expand Down
4 changes: 2 additions & 2 deletions src/components/vmd-commune-selector.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {classMap} from "lit-html/directives/class-map";
import {Commune, Departement} from "../state/State";
import {repeat} from "lit-html/directives/repeat";
import communeSelectorCss from "./vmd-commune-selector.component.scss";
import globalCss from "../styles/global.scss";
import {Strings} from "../utils/Strings";
import {TemplateResult} from "lit-html";
import {DirectiveFn} from "lit-html/lib/directive";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";


export type AutocompleteTriggered = { value: string };
Expand All @@ -26,7 +26,7 @@ export class VmdCommuneSelectorComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`${unsafeCSS(communeSelectorCss)}`,
css`
`
Expand Down
4 changes: 2 additions & 2 deletions src/components/vmd-departement-selector.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {LitElement, html, customElement, property, css, unsafeCSS} from 'lit-element'
import {repeat} from "lit-html/directives/repeat";
import globalCss from "../styles/global.scss";
import {CodeDepartement, Departement} from "../state/State";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

export type DepartementSelected = { departement: Departement|undefined };

Expand All @@ -10,7 +10,7 @@ export class VmdDepartementSelectorComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`
:host {
display: block;
Expand Down
4 changes: 2 additions & 2 deletions src/components/vmd-selector.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {css, customElement, html, LitElement, property, unsafeCSS} from "lit-element";
import globalCss from "../styles/global.scss";
import {repeat} from "lit-html/directives/repeat";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

export type ValueStrCustomEvent<T extends string> = CustomEvent<{value: T}>;

Expand All @@ -14,7 +14,7 @@ export class VmdSelectorComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`
:host {
display: block;
Expand Down
4 changes: 2 additions & 2 deletions src/components/vmd-tranche-age-selector.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {css, customElement, html, LitElement, property, unsafeCSS} from "lit-element";
import globalCss from "../styles/global.scss";
import {CodeTrancheAge, TrancheAge} from "../state/State";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

export type TrancheAgeSelectionne = { trancheAge: TrancheAge|undefined };

Expand All @@ -9,7 +9,7 @@ export class VmdTrancheAgeSelectorComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`
:host {
display: block;
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './styles/global.scss'
import './vmd-app.component'
import './components/vmd-tranche-age-selector.component'
import './components/vmd-departement-selector.component'
Expand Down
7 changes: 7 additions & 0 deletions src/styles/ConstructibleStyleSheets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {css, unsafeCSS} from "lit-element";
import globalCss from "./global.scss";
import homeCss from "../views/vmd-home.view.scss";


export const CSS_Global = css`${unsafeCSS(globalCss)}`
export const CSS_Home = css`${unsafeCSS(homeCss)}`
7 changes: 3 additions & 4 deletions src/views/vmd-home.view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {css, customElement, html, LitElement, property, unsafeCSS} from 'lit-element';
import {Router} from "../routing/Router";
import globalCss from "../styles/global.scss";
import homeViewCss from "./vmd-home.view.scss";
import {
Commune,
Departement,
Expand All @@ -16,14 +14,15 @@ import {
CommuneSelected,
DepartementSelected
} from "../components/vmd-commune-selector.component";
import {CSS_Global, CSS_Home} from "../styles/ConstructibleStyleSheets";

@customElement('vmd-home')
export class VmdHomeView extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
css`${unsafeCSS(homeViewCss)}`,
CSS_Global,
CSS_Home,
css`
:host {
display: block;
Expand Down
4 changes: 2 additions & 2 deletions src/views/vmd-lieux.view.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {css, customElement, html, LitElement, unsafeCSS} from 'lit-element';
import globalCss from "../styles/global.scss";
import {Icon, map, marker, tileLayer} from 'leaflet'
import leafletCss from 'leaflet/dist/leaflet.css';
import leafletMarkerCss from 'leaflet.markercluster/dist/MarkerCluster.Default.css';
// @ts-ignore
import {MarkerClusterGroup} from 'leaflet.markercluster'
import {Router} from "../routing/Router";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

// Code imported (and refactored a little bit)
// from https://github.com/rozierguillaume/covidtracker-tools/blob/main/src/ViteMaDose/carteCentres.html
Expand All @@ -27,7 +27,7 @@ export class VmdLieuxView extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`${unsafeCSS(leafletCss)}`,
css`${unsafeCSS(leafletMarkerCss)}`,
css`
Expand Down
4 changes: 2 additions & 2 deletions src/views/vmd-rdv.view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {css, customElement, html, LitElement, property, unsafeCSS} from 'lit-element';
import {repeat} from "lit-html/directives/repeat";
import {styleMap} from "lit-html/directives/style-map";
import globalCss from "../styles/global.scss";
import {Router} from "../routing/Router";
import rdvViewCss from "./vmd-rdv.view.scss";
import distanceEntreDeuxPoints from "../distance"
Expand Down Expand Up @@ -31,14 +30,15 @@ import {Analytics} from "../utils/Analytics";
import {LieuCliqueCustomEvent} from "../components/vmd-appointment-card.component";
import {setDebouncedInterval} from "../utils/Schedulers";
import {ArrayBuilder} from "../utils/Arrays";
import {CSS_Global} from "../styles/ConstructibleStyleSheets";

const MAX_DISTANCE_CENTRE_IN_KM = 100;

export abstract class AbstractVmdRdvView extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`${unsafeCSS(rdvViewCss)}`,
css`
`
Expand Down
8 changes: 3 additions & 5 deletions src/views/vmd-statistiques.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import '../components/graphs/vmd-stats-by-date-centres-graph.component'

import {css, customElement, html, LitElement, property, unsafeCSS} from 'lit-element';

import globalCss from "../styles/global.scss";
import homeViewCss from "../views/vmd-home.view.scss";

import {
State,
StatsByDate,
StatsLieu,
} from "../state/State";
import {CSS_Global, CSS_Home} from "../styles/ConstructibleStyleSheets";

@customElement('vmd-statistiques')
export class VmdLieuxStatistiques extends LitElement {
static styles = [
css`${unsafeCSS(globalCss)}`,
css`${unsafeCSS(homeViewCss)}`,
CSS_Global,
CSS_Home,
css`
:host {
display: block;
Expand Down
4 changes: 2 additions & 2 deletions src/vmd-app.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {LitElement, html, customElement, property, css, unsafeCSS} from 'lit-element';
import {Router, SlottedTemplateResultFactory} from "./routing/Router";
import globalCss from './styles/global.scss'
import {CSS_Global} from "./styles/ConstructibleStyleSheets";

@customElement('vmd-app')
export class VmdAppComponent extends LitElement {

//language=css
static styles = [
css`${unsafeCSS(globalCss)}`,
CSS_Global,
css`
.appLogo {}
.appLogo._phone {
Expand Down

0 comments on commit 3aeda9f

Please sign in to comment.