-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: change moment to date-utils (#198)
* feat!: remove moment * fix(Highcharts plugin): fix lang changing * chore: add @gravity-ui/eslint-config/prettier to eslintrc
- Loading branch information
Showing
14 changed files
with
107 additions
and
63 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": ["@gravity-ui/eslint-config", "@gravity-ui/eslint-config/client"], | ||
"extends": [ | ||
"@gravity-ui/eslint-config", | ||
"@gravity-ui/eslint-config/client", | ||
"@gravity-ui/eslint-config/prettier" | ||
], | ||
"root": true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import React from 'react'; | ||
import type {DecoratorFn} from '@storybook/react'; | ||
import type {Decorator} from '@storybook/react'; | ||
import {Lang, configure} from '@gravity-ui/uikit'; | ||
import {settings as dateUtilsSettings} from '@gravity-ui/date-utils'; | ||
import {settings as chartkitSettings} from '../../src/libs'; | ||
|
||
export const withLang: DecoratorFn = (Story, context) => { | ||
const lang = context.globals.lang; | ||
const setDateUtilsLocale = async (lang: string) => { | ||
await dateUtilsSettings.loadLocale(lang); | ||
dateUtilsSettings.setLocale(lang); | ||
}; | ||
|
||
configure({ | ||
lang: lang as Lang, | ||
}); | ||
export const withLang: Decorator = (Story, context) => { | ||
const lang = context.globals.lang; | ||
chartkitSettings.set({lang}); | ||
setDateUtilsLocale(lang); | ||
configure({lang: lang as Lang}); | ||
|
||
return <Story key={lang} {...context} />; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
type EventObject<T = unknown> = { | ||
id: string; | ||
action: (args: T) => void; | ||
}; | ||
|
||
export class EventEmitter<EventsMap = unknown> { | ||
private events = {} as Record<keyof EventsMap, EventObject<any>[]>; | ||
|
||
on<MapKey extends keyof EventsMap>(type: MapKey, event: EventObject<EventsMap[MapKey]>) { | ||
if (this.events[type]) { | ||
this.events[type].push(event); | ||
} else { | ||
this.events[type] = [event]; | ||
} | ||
} | ||
|
||
off<MapKey extends keyof EventsMap>(type: MapKey, eventId: string) { | ||
if (this.events[type]) { | ||
this.events[type] = this.events[type].filter(({id}) => id !== eventId); | ||
} | ||
} | ||
|
||
dispatch<MapKey extends keyof EventsMap>(type: MapKey, args: EventsMap[MapKey]) { | ||
if (this.events[type]) { | ||
this.events[type].forEach(({action}) => { | ||
action(args); | ||
}); | ||
} | ||
} | ||
} |
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 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 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 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 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 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 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 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