ui/src/
/entrypoints/main.ts
/store/configureStore.ts
/rootReducer.ts
/components/gallery/
/actions.ts
/gallery.scss
/dom.ts
/middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const strictCustomEvent = < | |
T extends keyof Omit<DocumentEventMap, defaultDocumentEventNames>, | |
D extends UnpackCustomEventPayload<DocumentEventMap[T]> | |
>( | |
name: T, | |
payload: Omit<CustomEventInit<D>, "detail"> & { | |
detail: D | |
} | |
): CustomEvent<D> => new CustomEvent(name, payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L3307 | |
declare var CustomEvent: { | |
prototype: CustomEvent; | |
new <T>(typeArg: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ClassifiedListFilterUpdate = "CL_FILTER_UPDATE"; | |
export type ClassifiedListFilterUpdate = { | |
searchUrls: { | |
/** | |
* Search url with legacy parameters | |
*/ | |
legacy: string; | |
/** | |
* Search url with newer `mmm` parameters | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib.dom.d.ts section | |
// https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L4450 | |
addEventListener<K extends keyof DocumentEventMap>( | |
type: K, | |
listener: (this: Document, ev: DocumentEventMap[K]) => any, | |
options?: boolean | AddEventListenerOptions | |
): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere in another app... | |
import { ListPage, strictCustomEvent } from "@autoscout24/custom-events"; | |
document.dispatchEvent( | |
strictCustomEvent(ListPage.ClassifiedListTotalCountUpdate, { | |
detail: { | |
totalCount: 42 | |
} | |
}) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere in your app... | |
import { ListPage } from "@autoscout24/custom-events"; | |
document.addEventListener(ListPage.ClassifiedListFilterUpdate, e => | |
console.log(e.detail.searchUrls.standard) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Redux from "redux"; | |
import Config from "./config"; // some config | |
import { State } from "../../store/rootReducer"; | |
import * as actions from "./actions"; | |
import { listeners as domListeners, mutations as domMutations } from "./dom"; | |
/** | |
* Middleware to schedule dom mutations based on redux actions / state changes | |
*/ | |
export const middleware = (_: Config) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@() | |
<div id="some-dom-id" class="gallery"> | |
<h5>Redux Example </h5> | |
<div class="image-wrapper"> | |
@* Generate list of random images for demo purposes *@ | |
@for(i <- 1 to 5) { | |
<img src="https://source.unsplash.com/random/300x300?sig=@{i}" /> | |
} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some CSS styles for our component | |
import "./gallery.scss"; | |
/** | |
* DOM mutations. Include all DOM manipulation for this component here | |
*/ | |
export const mutations = { | |
select: (index: number) => { | |
mutations.clearSelected(); | |
const images = elements.images(); |
NewerOlder