-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate remaining components to TypeScript (#2065)
* Migrate AspectRatio to TypeScript * Migrate Calendar components to TypeScript * Migrate Tabs to TypeScript * Migrate Carousel to TypeScript * Migrate Sidebar to TypeScript * Remove shared prop types * Add changesets
- Loading branch information
1 parent
fef5b95
commit 8adb8fe
Showing
100 changed files
with
1,256 additions
and
1,074 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sumup/circuit-ui': minor | ||
--- | ||
|
||
Migrated the Tabs components to TypeScript. |
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,5 @@ | ||
--- | ||
'@sumup/circuit-ui': major | ||
--- | ||
|
||
Removed the `sharedPropTypes` export. Type the props using TypeScript instead. |
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,5 @@ | ||
--- | ||
'@sumup/circuit-ui': major | ||
--- | ||
|
||
Migrated the Carousel components to TypeScript. Added the required `playButtonLabel`, `pauseButtonLabel`, `prevButtonLabel`, and `nextButtonLabel` props. |
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,5 @@ | ||
--- | ||
'@sumup/circuit-ui': minor | ||
--- | ||
|
||
Migrated the Sidebar component to TypeScript. |
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,5 @@ | ||
--- | ||
'@sumup/circuit-ui': major | ||
--- | ||
|
||
Migrated the Calendar components to TypeScript. Some props are now required. The CalendarTagTwoStep's `clearText` and `confirmText` props have been renamed to `clearButtonLabel` and `confirmButtonLabel` respectively. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
94 changes: 0 additions & 94 deletions
94
packages/circuit-ui/components/AspectRatio/AspectRatio.jsx
This file was deleted.
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
77 changes: 77 additions & 0 deletions
77
packages/circuit-ui/components/AspectRatio/AspectRatio.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,77 @@ | ||
/** | ||
* Copyright 2019, SumUp Ltd. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Children, forwardRef, cloneElement, ReactElement } from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { ClassNames, css, ClassNamesContent } from '@emotion/react'; | ||
|
||
export interface AspectRatioProps { | ||
children?: ReactElement; | ||
aspectRatio?: number; | ||
} | ||
|
||
const wrapperStyles = ({ aspectRatio }: { aspectRatio: number }) => css` | ||
display: block; | ||
position: relative; | ||
overflow: hidden; | ||
height: 0; | ||
width: 100%; | ||
padding-top: ${Math.round((1 / aspectRatio) * 100)}%; | ||
`; | ||
|
||
const Wrapper = styled('div')(wrapperStyles); | ||
|
||
const childStyles = (context: ClassNamesContent) => context.css` | ||
display: block; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
z-index: ${context.theme.zIndex.absolute}; | ||
`; | ||
|
||
export const AspectRatio = forwardRef<HTMLDivElement, AspectRatioProps>( | ||
({ aspectRatio, children, ...props }, ref) => { | ||
if (!children) { | ||
return null; | ||
} | ||
|
||
const child = Children.only(children); | ||
|
||
if (!aspectRatio) { | ||
return ( | ||
<div ref={ref} {...props}> | ||
{child} | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<Wrapper ref={ref} aspectRatio={aspectRatio} {...props}> | ||
<ClassNames> | ||
{(context) => | ||
cloneElement(child, { className: childStyles(context) }) | ||
} | ||
</ClassNames> | ||
</Wrapper> | ||
); | ||
}, | ||
); | ||
|
||
AspectRatio.displayName = 'AspectRatio'; |
Oops, something went wrong.