-
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.
Showing
13 changed files
with
351 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as stylex from '@stylexjs/stylex'; | ||
import type { StyleXStyles } from '@stylexjs/stylex'; | ||
import type { UserAuthoredStyles } from '@stylexjs/stylex/lib/StyleXTypes'; | ||
import { type AnchorHTMLAttributes, forwardRef, memo } from 'react'; | ||
import { sizes, styls } from './buttonViteStyle'; | ||
|
||
interface Props extends AnchorHTMLAttributes<HTMLAnchorElement> { | ||
size?: 'small' | 'medium' | 'large'; | ||
styles?: StyleXStyles<UserAuthoredStyles>; | ||
} | ||
|
||
const Component = forwardRef<HTMLAnchorElement, Props>( | ||
({ size = 'medium', styles, children, ...attrs }, ref) => ( | ||
<a | ||
ref={ref} | ||
{...stylex.props(styls.base, sizes[size], styles)} | ||
{...attrs} | ||
> | ||
{children} | ||
</a> | ||
), | ||
); | ||
|
||
export const ButtonViteAnchor = memo(Component); |
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,49 @@ | ||
import stylex from '@stylexjs/stylex'; | ||
|
||
export const styls = stylex.create({ | ||
base: { | ||
fontFamily: 'inherit', | ||
color: '#646cff', | ||
display: 'grid', | ||
placeItems: 'center', | ||
cursor: 'pointer', | ||
backgroundColor: { | ||
default: '#1a1a1a', | ||
'@media (prefers-color-scheme: dark)': '#1a1a1a', | ||
'@media (prefers-color-scheme: light)': '#f9f9f9', | ||
}, | ||
outline: 'none', // デフォルトのスタイル対策 | ||
borderWidth: 1, | ||
borderStyle: 'solid', | ||
borderColor: { | ||
default: 'transparent', | ||
':hover': '#646cff', | ||
':focus': '#eee', | ||
':focus-visible': '#eee', | ||
}, | ||
borderRadius: 8, | ||
transition: 'border-color 0.25s', | ||
willChange: 'border-color', | ||
}, | ||
}); | ||
|
||
export const sizes = stylex.create({ | ||
small: { | ||
width: 96, | ||
height: 32, | ||
fontSize: '0.8em', | ||
fontWeight: 300, | ||
}, | ||
medium: { | ||
width: 128, | ||
height: 48, | ||
fontSize: '1em', | ||
fontWeight: 500, | ||
}, | ||
large: { | ||
width: 160, | ||
height: 64, | ||
fontSize: '1.2em', | ||
fontWeight: 700, | ||
}, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import type { StyleXStyles } from '@stylexjs/stylex'; | ||
import type { UserAuthoredStyles } from '@stylexjs/stylex/lib/StyleXTypes'; | ||
import type { HTMLAttributes } from 'react'; | ||
|
||
export interface Props extends HTMLAttributes<HTMLHeadingElement> { | ||
isLeft?: boolean; | ||
propsStyles?: StyleXStyles<UserAuthoredStyles>; | ||
} |
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,68 @@ | ||
import stylex from '@stylexjs/stylex'; | ||
import { type FC, memo, useCallback, useRef } from 'react'; | ||
import { ButtonVite } from '../../components/button/ButtonVite'; | ||
import { DivCustom } from '../../components/div/DivCustom'; | ||
import { useScrollSmooth } from '../../hooks/useScrollSmooth'; | ||
import { ScrollCss } from './ScrollCss'; | ||
import { ScrollDiv } from './ScrollDiv'; | ||
import { stylesCommon } from './styles'; | ||
|
||
const styles = stylex.create({ | ||
wrap: { | ||
height: '200lvh', | ||
}, | ||
fixed: { | ||
position: 'fixed', | ||
right: 0, | ||
bottom: 0, | ||
}, | ||
}); | ||
|
||
const Component: FC = () => { | ||
const refWindowTarget = useRef<HTMLDivElement>(null); | ||
|
||
const { scrollSmooth } = useScrollSmooth(); | ||
|
||
const getNewTopWindow = useCallback(() => { | ||
const topMax = window.innerHeight; | ||
const topNow = window.scrollY; | ||
const topSub = topMax / 4; | ||
return topNow >= topMax - 1 ? 0 : Math.min(topNow + topSub, topMax); | ||
}, []); | ||
|
||
const scrollWindowNormal = useCallback(() => { | ||
window.scrollTo(0, getNewTopWindow()); | ||
}, [getNewTopWindow]); | ||
|
||
const scrollWindowSmooth = useCallback(() => { | ||
scrollSmooth(refWindowTarget, getNewTopWindow()); | ||
}, [getNewTopWindow, scrollSmooth]); | ||
|
||
return ( | ||
<DivCustom styles={styles.wrap}> | ||
{/* Divスクロール */} | ||
<ScrollDiv /> | ||
{/* CSSスクロール */} | ||
<ScrollCss /> | ||
{/* Windowスクロール */} | ||
<div | ||
ref={refWindowTarget} | ||
id='window-target' | ||
{...stylex.props(stylesCommon.target)} | ||
/> | ||
<DivCustom | ||
styleTypes={['flexColumn', 'gap', 'margin']} | ||
styles={styles.fixed} | ||
> | ||
<ButtonVite size='large' onClick={scrollWindowNormal}> | ||
Normal Scroll | ||
</ButtonVite> | ||
<ButtonVite size='large' onClick={scrollWindowSmooth}> | ||
Smooth Scroll | ||
</ButtonVite> | ||
</DivCustom> | ||
</DivCustom> | ||
); | ||
}; | ||
|
||
export const Scroll = memo(Component); |
Oops, something went wrong.