Skip to content

Commit

Permalink
refactor: arrange types
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ng-d committed Sep 1, 2024
1 parent d26c549 commit 39ab6d5
Show file tree
Hide file tree
Showing 21 changed files with 115 additions and 127 deletions.
62 changes: 60 additions & 2 deletions src/types/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { HighlightStatus } from './management'

export interface Feature {
name: string
description: string
Expand Down Expand Up @@ -41,6 +39,21 @@ export type PlanStatus = 'UNPAID' | 'PAID' | 'NOT_SUPPORTED'

export type TrialStatus = 'UNUSED' | 'PENDING' | 'EXPIRED'

export type FetchStatus =
| 'UNLOADED'
| 'LOADING'
| 'LOADED'
| 'ERROR'
| 'EMPTY'
| 'COMPLETE'
| 'SIGN_IN_FIRST'
| 'NO_RESULT'

export type HighlightStatus =
| 'NO_HIGHLIGHT'
| 'DISPLAY_HIGHLIGHT_NOTIFICATION'
| 'DISPLAY_HIGHLIGHT_DIALOG'

export type Language = 'en-US'

export interface windowSize {
Expand All @@ -52,3 +65,48 @@ export interface HighlightDigest {
version: string
status: HighlightStatus
}

export interface SelectedColor {
id: string | undefined
position: number
}

export interface HoveredColor extends SelectedColor {
hasGuideAbove: boolean
hasGuideBelow: boolean
}

export type PriorityContext =
| 'EMPTY'
| 'FEEDBACK'
| 'TRIAL_FEEDBACK'
| 'HIGHLIGHT'
| 'WELCOME_TO_PRO'
| 'WELCOME_TO_TRIAL'
| 'TRY'
| 'ABOUT'
| 'PUBLICATION'
| 'REPORT'

export type ThirdParty = 'COOLORS' | 'REALTIME_COLORS' | 'COLOUR_LOVERS'

export type Easing = 'LINEAR' | 'EASE_IN' | 'EASE_OUT' | 'EASE_IN_OUT'

export interface ImportUrl {
value: string
state: 'DEFAULT' | 'ERROR' | undefined
canBeSubmitted: boolean
helper:
| {
type: 'INFO' | 'ERROR'
message: string
}
| undefined
}

export interface ContextItem {
label: string
id: Context
isUpdated: boolean
isActive: boolean
}
2 changes: 1 addition & 1 deletion src/types/configurations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HexModel } from '@a_ng_d/figmug-ui'

import { ThirdParty } from './management'
import { ThirdParty } from './app'
import { RgbModel, TextColorsThemeHexModel } from './models'

export interface SourceColorConfiguration {
Expand Down
9 changes: 0 additions & 9 deletions src/types/content.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/types/events.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { EditorType } from './app'
import { Easing, EditorType } from './app'
import {
ColorSpaceConfiguration,
NamingConventionConfiguration,
} from './configurations'
import { Easing } from './management'

export interface EditorEvent {
editor: EditorType
Expand Down
61 changes: 0 additions & 61 deletions src/types/management.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
HighlightDigest,
Language,
PlanStatus,
PriorityContext,
Service,
TrialStatus,
} from '../types/app'
Expand All @@ -33,7 +34,6 @@ import {
ViewConfiguration,
VisionSimulationModeConfiguration,
} from '../types/configurations'
import { PriorityContext } from '../types/management'
import { ActionsList, TextColorsThemeHexModel } from '../types/models'
import { UserSession } from '../types/user'
import features, {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { doMap } from '@a-ng-d/figmug.modules.do-map'
import React from 'react'

import { Easing } from '../../types/app'
import { ScaleConfiguration } from '../../types/configurations'
import { Easing } from '../../types/management'
import doLightnessScale from '../../utils/doLightnessScale'
import { palette } from '../../utils/palettePackage'
import addStop from './../handlers/addStop'
Expand Down
9 changes: 7 additions & 2 deletions src/ui/contexts/Colors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import React from 'react'
import { uid } from 'uid'

import { locals } from '../../content/locals'
import { EditorType, Language, PlanStatus } from '../../types/app'
import {
EditorType,
HoveredColor,
Language,
PlanStatus,
SelectedColor,
} from '../../types/app'
import { ColorConfiguration } from '../../types/configurations'
import { HoveredColor, SelectedColor } from '../../types/management'
import { ColorsMessage } from '../../types/messages'
import { ActionsList, DispatchProcess } from '../../types/models'
import { Identity } from '../../types/user'
Expand Down
12 changes: 3 additions & 9 deletions src/ui/contexts/CommunityPalettes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react'

import { supabase } from '../../bridges/publication/authentication'
import { locals } from '../../content/locals'
import { Context, Language, PlanStatus } from '../../types/app'
import { Context, FetchStatus, Language, PlanStatus } from '../../types/app'
import {
ColorConfiguration,
MetaConfiguration,
Expand All @@ -19,7 +19,6 @@ import {
ThemeConfiguration,
} from '../../types/configurations'
import { ExternalPalettes } from '../../types/data'
import { FetchStatus } from '../../types/management'
import { ActionsList } from '../../types/models'
import { UserSession } from '../../types/user'
import { pageSize, palettesDbTableName } from '../../utils/config'
Expand Down Expand Up @@ -412,16 +411,11 @@ export default class CommunityPalettes extends React.Component<
)
}}
onCleared={(e) => {
this.props.onChangeSearchQuery(
e
)
this.props.onChangeSearchQuery(e)
this.props.onChangeStatus('LOADING')
this.props.onChangeCurrentPage(1)
this.props.onLoadPalettesList([])
this.callUICPAgent(
1,
e
)
this.callUICPAgent(1, e)
}}
/>
}
Expand Down
8 changes: 6 additions & 2 deletions src/ui/contexts/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import React from 'react'
import { uid } from 'uid'

import { locals } from '../../content/locals'
import { FilterOptions, Language } from '../../types/app'
import {
FetchStatus,
FilterOptions,
Language,
ThirdParty,
} from '../../types/app'
import { SourceColorConfiguration } from '../../types/configurations'
import { ColourLovers } from '../../types/data'
import { FetchStatus, ThirdParty } from '../../types/management'
import { pageSize } from '../../utils/config'
import { trackImportEvent } from '../../utils/eventsTracker'
import PaletteItem from '../components/PaletteItem'
Expand Down
12 changes: 3 additions & 9 deletions src/ui/contexts/MyPalettes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { signIn, supabase } from '../../bridges/publication/authentication'
import sharePalette from '../../bridges/publication/sharePalette'
import unpublishPalette from '../../bridges/publication/unpublishPalette'
import { locals } from '../../content/locals'
import { Context, Language, PlanStatus } from '../../types/app'
import { Context, FetchStatus, Language, PlanStatus } from '../../types/app'
import {
ColorConfiguration,
MetaConfiguration,
Expand All @@ -22,7 +22,6 @@ import {
ThemeConfiguration,
} from '../../types/configurations'
import { ExternalPalettes } from '../../types/data'
import { FetchStatus } from '../../types/management'
import { ActionsList } from '../../types/models'
import { UserSession } from '../../types/user'
import { pageSize, palettesDbTableName } from '../../utils/config'
Expand Down Expand Up @@ -643,16 +642,11 @@ export default class MyPalettes extends React.Component<
)
}}
onCleared={(e) => {
this.props.onChangeSearchQuery(
e
)
this.props.onChangeSearchQuery(e)
this.props.onChangeStatus('LOADING')
this.props.onChangeCurrentPage(1)
this.props.onLoadPalettesList([])
this.callUICPAgent(
1,
e
)
this.callUICPAgent(1, e)
}}
/>
}
Expand Down
3 changes: 1 addition & 2 deletions src/ui/contexts/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import React from 'react'
import { uid } from 'uid'

import { locals } from '../../content/locals'
import { Language, PlanStatus } from '../../types/app'
import { ImportUrl, Language, PlanStatus, ThirdParty } from '../../types/app'
import { SourceColorConfiguration } from '../../types/configurations'
import { ImportUrl, ThirdParty } from '../../types/management'
import features from '../../utils/config'
import { trackImportEvent } from '../../utils/eventsTracker'
import isBlocked from '../../utils/isBlocked'
Expand Down
3 changes: 1 addition & 2 deletions src/ui/contexts/Palettes.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Bar, ConsentConfiguration, HexModel, Tabs } from '@a_ng_d/figmug-ui'
import React from 'react'

import { Language, PlanStatus } from '../../types/app'
import { ContextItem, FetchStatus, Language, PlanStatus } from '../../types/app'
import { ExternalPalettes } from '../../types/data'
import { ContextItem, FetchStatus } from '../../types/management'
import { UserSession } from '../../types/user'
import { setContexts } from '../../utils/setContexts'
import CommunityPalettes from './CommunityPalettes'
Expand Down
3 changes: 1 addition & 2 deletions src/ui/contexts/Scale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import {
import React from 'react'

import { locals } from '../../content/locals'
import { EditorType, Language, PlanStatus } from '../../types/app'
import { Easing, EditorType, Language, PlanStatus } from '../../types/app'
import {
NamingConventionConfiguration,
PresetConfiguration,
ScaleConfiguration,
SourceColorConfiguration,
} from '../../types/configurations'
import { Easing } from '../../types/management'
import { ScaleMessage } from '../../types/messages'
import { ActionsList, DispatchProcess } from '../../types/models'
import { Identity } from '../../types/user'
Expand Down
3 changes: 2 additions & 1 deletion src/ui/contexts/Source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { Bar, ConsentConfiguration, Tabs } from '@a_ng_d/figmug-ui'
import React from 'react'

import {
ContextItem,
EditorType,
FilterOptions,
Language,
PlanStatus,
ThirdParty,
} from '../../types/app'
import { SourceColorConfiguration } from '../../types/configurations'
import { ColourLovers } from '../../types/data'
import { ContextItem, ThirdParty } from '../../types/management'
import features from '../../utils/config'
import { setContexts } from '../../utils/setContexts'
import Feature from '../components/Feature'
Expand Down
9 changes: 7 additions & 2 deletions src/ui/contexts/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import React from 'react'
import { uid } from 'uid'

import { locals } from '../../content/locals'
import { EditorType, Language, PlanStatus } from '../../types/app'
import {
EditorType,
HoveredColor,
Language,
PlanStatus,
SelectedColor,
} from '../../types/app'
import {
PresetConfiguration,
ScaleConfiguration,
ThemeConfiguration,
} from '../../types/configurations'
import { HoveredColor, SelectedColor } from '../../types/management'
import { ThemesMessage } from '../../types/messages'
import { ActionsList, DispatchProcess } from '../../types/models'
import { Identity } from '../../types/user'
Expand Down
Loading

0 comments on commit 39ab6d5

Please sign in to comment.