-
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.
style: change colors and spaces (#1611)
- Loading branch information
Showing
19 changed files
with
125 additions
and
123 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
43 changes: 39 additions & 4 deletions
43
packages/extension-polkagate/src/components/VaadinIcon.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 |
---|---|---|
@@ -1,16 +1,51 @@ | ||
// Copyright 2019-2024 @polkadot/extension-polkagate authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// @ts-nocheck | ||
|
||
import React from 'react'; | ||
import '@vaadin/icons'; | ||
|
||
import React, { useEffect } from 'react'; | ||
|
||
interface VaadinIconProps extends React.HTMLAttributes<HTMLElement> { | ||
icon: string; | ||
spin?: boolean; | ||
float?: boolean; | ||
} | ||
|
||
const VaadinIcon: React.FC<VaadinIconProps> = ({ icon, ...props }) => { | ||
return <vaadin-icon icon={icon} {...props} />; | ||
const VaadinIcon: React.FC<VaadinIconProps> = ({ float = false, icon, spin = false, style, ...props }) => { | ||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; | ||
|
||
useEffect(() => { | ||
// Check if the animations are already injected | ||
if (!document.getElementById('vaadin-icon-animation-keyframes')) { | ||
const styleSheet = document.createElement('style'); | ||
|
||
styleSheet.id = 'vaadin-icon-animation-keyframes'; | ||
styleSheet.innerText = ` | ||
@keyframes vaadinSpin { | ||
from { transform: rotate(0deg); } | ||
to { transform: rotate(360deg); } | ||
} | ||
@keyframes float { | ||
0%, 100% { transform: translateY(0); } | ||
50% { transform: translateY(-4px); } | ||
} | ||
`; | ||
document.head.appendChild(styleSheet); | ||
} | ||
}, []); | ||
|
||
// Combine inline styles with the animations if enabled | ||
const combinedStyles: React.CSSProperties = { | ||
animation: `${spin && !prefersReducedMotion ? 'vaadinSpin 3s linear infinite' : ''} ${float && !prefersReducedMotion ? 'float 2s ease-in-out infinite' : ''}`, | ||
...style | ||
}; | ||
|
||
// @ts-ignore | ||
return <vaadin-icon | ||
icon={icon} | ||
style={combinedStyles} | ||
{...props} | ||
/>; | ||
}; | ||
|
||
export default VaadinIcon; |
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.