-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from CSSSR/release/core-21-45
Release: Core-21-45
- Loading branch information
Showing
14 changed files
with
79 additions
and
106 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
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
43 changes: 43 additions & 0 deletions
43
packages/core-design/src/components/Footer/DoubleBottom/Addresses/Time/Time.tsx
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,43 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import Text from '../../../../Text' | ||
|
||
export interface Props { | ||
id: string | ||
textSize: 'm'|'s' | ||
className?: string | ||
timeZone: string | ||
} | ||
|
||
export const Time: React.FC<Props> = ({ className, id, textSize, timeZone}) => { | ||
const [time, setTime] = useState(new Date()) | ||
// Обновляем время раз в минуту | ||
const DELAY_TIME_UPDATE = 60000 | ||
|
||
useEffect(() => { | ||
const timeout = setTimeout(() => { | ||
setTime(new Date()) | ||
}, DELAY_TIME_UPDATE) | ||
|
||
return () => clearTimeout(timeout) | ||
}) | ||
|
||
const getTime = () => { | ||
/* show only hours and minutes, use options with the default locale - use an empty array, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString */ | ||
return time.toLocaleTimeString([], { | ||
timeZone, | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}) | ||
} | ||
|
||
return ( | ||
<Text | ||
className={className} | ||
type="regular" | ||
size={textSize} | ||
data-testid={`Footer:text:address.time.${id}`} | ||
> | ||
{getTime()} | ||
</Text> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/core-design/src/components/Footer/DoubleBottom/Addresses/Time/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Time' |
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
Oops, something went wrong.