WIP snake_case 1/?

through `contact_notification`
This commit is contained in:
Nate Butler
2023-06-28 22:42:57 -04:00
parent 2e162f8af7
commit b015f506da
41 changed files with 302 additions and 386 deletions
+20 -20
View File
@@ -43,55 +43,55 @@ export function interactive<T extends object>({
}: InteractiveProps<T>): Interactive<T> {
if (!base && !state.default) throw new Error(NO_DEFAULT_OR_BASE_ERROR)
let defaultState: T
let default_state: T
if (state.default && base) {
defaultState = merge(base, state.default) as T
default_state = merge(base, state.default) as T
} else {
defaultState = base ? base : (state.default as T)
default_state = base ? base : (state.default as T)
}
const interactiveObj: Interactive<T> = {
default: defaultState,
const interactive_obj: Interactive<T> = {
default: default_state,
}
let stateCount = 0
let state_count = 0
if (state.hovered !== undefined) {
interactiveObj.hovered = merge(
interactiveObj.default,
interactive_obj.hovered = merge(
interactive_obj.default,
state.hovered
) as T
stateCount++
state_count++
}
if (state.clicked !== undefined) {
interactiveObj.clicked = merge(
interactiveObj.default,
interactive_obj.clicked = merge(
interactive_obj.default,
state.clicked
) as T
stateCount++
state_count++
}
if (state.selected !== undefined) {
interactiveObj.selected = merge(
interactiveObj.default,
interactive_obj.selected = merge(
interactive_obj.default,
state.selected
) as T
stateCount++
state_count++
}
if (state.disabled !== undefined) {
interactiveObj.disabled = merge(
interactiveObj.default,
interactive_obj.disabled = merge(
interactive_obj.default,
state.disabled
) as T
stateCount++
state_count++
}
if (stateCount < 1) {
if (state_count < 1) {
throw new Error(NOT_ENOUGH_STATES_ERROR)
}
return interactiveObj
return interactive_obj
}
+4 -4
View File
@@ -35,13 +35,13 @@ export function toggleable<T extends object>(
if (!base && !state.inactive) throw new Error(NO_INACTIVE_OR_BASE_ERROR)
if (!state.active) throw new Error(NO_ACTIVE_ERROR)
const inactiveState = base
const inactive_state = base
? ((state.inactive ? merge(base, state.inactive) : base) as T)
: (state.inactive as T)
const toggleObj: Toggleable<T> = {
inactive: inactiveState,
const toggle_obj: Toggleable<T> = {
inactive: inactive_state,
active: merge(base ?? {}, state.active) as T,
}
return toggleObj
return toggle_obj
}