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
module Parser | |
import Data.Nat | |
import Data.List | |
%default total | |
-- interface Codec input output where | |
-- encode : input -> output | |
-- decode : output -> Maybe input |
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 type Outcome<Value, Report> = { type: "valid"; value: Value } | { type: "invalid"; reports: Array<Report> }; | |
export type ValidatorSyncBase<Value, Report> = { | |
validateSync(value: unknown): Outcome<Value, Report>; | |
}; | |
export function makeValidatorSync<const Value, const Report>(validatorSyncBase: ValidatorSyncBase<Value, Report>) { | |
return { | |
...validatorSyncBase, | |
refine: refine(validatorSyncBase), |
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
apply plugin: 'maven-publish' | |
/* | |
* Fix NodeJS version | |
*/ | |
node.nodeVersion="20.11.1" | |
node.npmVersion="10.2.4" | |
/* | |
* Fix for artifact deploy |
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
- check with browser plugin "wave" and "axe" also chrome lighthouse accesibility | |
open chrome inspect element and see the accesibility tree | |
- generally copy accessibility from mui.com components | |
- banner role (first <header> in page) should contain title, logo, optionally nav | |
- contentinfo role (first <footer> in page) | |
- <main/> (ensure there is only one so that user can skip over heading and sides to most important content) | |
- <aside/> |
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 React from "react"; | |
export function useGeolocation({ | |
isEnabled, | |
positionOptions: { enableHighAccuracy, maximumAge, timeout }, | |
startTransition, | |
}: { | |
isEnabled: boolean; | |
positionOptions: PositionOptions; | |
startTransition?(update: () => void): 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
/** | |
* React hook to measure an element before rendering it | |
* given some jsx it renders it in a hidden div then measures its size | |
* the hook returns width and height and portal | |
* @important the portal must be in the page to be able to render the hidden div for measurements | |
* @warning the jsx will be renred probably twice, once for measurement, and where you actually use it | |
*/ | |
export function useDomSize(children: JSX.Element) { | |
const [width, setWidth] = React.useState(0); | |
const [height, setHeight] = React.useState(0); |
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
// this files goes to feature/configuration.json | |
// it lets you setup configuration fields for a portlet | |
// it work with an adapted create-react-app for liferay https://help.liferay.com/hc/en-us/articles/360035467712-Adapting-Existing-Apps-to-Run-on-Liferay-DXP | |
{ | |
"$schema": "https://raw.githubusercontent.com/liferay/liferay-js-toolkit/master/resources/schemas/configuration.schema.json", | |
"system": { | |
"category": "react-js-toolkit", | |
"name": "react-js-toolkit", | |
"fields": { | |
"fruit": { |
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 { setupWorker } from 'msw/browser' | |
// https://mswjs.io/docs/best-practices/typescript | |
// also ensure there is .env or env.local file | |
// with PUBLIC_URL=index set to something otherwise chrome wont load the mock service worker | |
const worker = setupWorker(/* here goes handlers */); | |
if (process.env.NODE_ENV === "development") { |
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
function useValueWithTimeToLive<T>() { | |
const [state, setState] = React.useState<{ value: T | undefined; timeToLive: number | undefined }>({ | |
value: undefined, | |
timeToLive: undefined, | |
}); | |
const setValueWithTimeToLive = React.useCallback((value: T, timeToLive: number) => { | |
setState({ value, timeToLive }); | |
}, []); | |
React.useEffect(() => { | |
if (state.timeToLive !== undefined) { |
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
function moveItem<T>(fromIndex: number, toIndex: number, array: Array<T>): Array<T> { | |
if (fromIndex < toIndex) { | |
return [...array.slice(0, fromIndex), ...array.slice(fromIndex + 1, toIndex + 1), array[fromIndex], ...array.slice(toIndex + 1)]; | |
} | |
if (fromIndex > toIndex) { | |
return [...array.slice(0, toIndex), array[fromIndex], ...array.slice(toIndex, fromIndex), ...array.slice(fromIndex + 1)]; | |
} | |
return array; | |
} |
NewerOlder