|
| 1 | +import { styled, keyframes } from 'stitches.config.js'; |
| 2 | + |
| 3 | +const Component = () => { |
| 4 | + return ( |
| 5 | + <Wrapper> |
| 6 | + <Gradient /> |
| 7 | + <Button>Hover me</Button> |
| 8 | + </Wrapper> |
| 9 | + ); |
| 10 | +}; |
| 11 | + |
| 12 | +const pulse = keyframes({ |
| 13 | + '0%': { |
| 14 | + transform: 'rotate(0deg)', |
| 15 | + filter: 'blur(8px)', |
| 16 | + borderRadius: 5 |
| 17 | + }, |
| 18 | + '33%': { |
| 19 | + transform: 'rotate(-0.5deg) translate(1px,-1px) scale(1.01)', |
| 20 | + filter: 'blur(10px)', |
| 21 | + borderRadius: 3 |
| 22 | + }, |
| 23 | + '67%': { |
| 24 | + transform: 'rotate(1deg) translate(-1px,-1px) scale(0.99)', |
| 25 | + filter: 'blur(14px)', |
| 26 | + borderRadius: 7 |
| 27 | + }, |
| 28 | + '100%': { |
| 29 | + transform: 'rotate(0deg)', |
| 30 | + filter: 'blur(8px)', |
| 31 | + borderRadius: 5 |
| 32 | + } |
| 33 | +}); |
| 34 | + |
| 35 | +const Gradient = styled('div', { |
| 36 | + filter: 'blur(1px)', |
| 37 | + borderRadius: '8px', |
| 38 | + position: 'absolute', |
| 39 | + top: '0px', |
| 40 | + left: '0px', |
| 41 | + width: '100%', |
| 42 | + height: '100%', |
| 43 | + transition: 'opacity 1.5s ease', |
| 44 | + background: 'linear-gradient(91.83deg, rgb(208, 60, 74) 2.26%, rgb(172, 74, 218) 95.81%)', |
| 45 | + animation: `10s ease-in-out 0s infinite normal both running ${pulse}`, |
| 46 | + opacity: '0.75' |
| 47 | +}); |
| 48 | + |
| 49 | +const Wrapper = styled('buton', { |
| 50 | + position: 'relative', |
| 51 | + padding: '1px', |
| 52 | + borderRadius: '$1', |
| 53 | + |
| 54 | + '&:hover': { |
| 55 | + [`& ${Gradient}`]: { |
| 56 | + transitionDuration: '0.25s', |
| 57 | + opacity: 1 |
| 58 | + } |
| 59 | + } |
| 60 | +}); |
| 61 | + |
| 62 | +const Button = styled('div', { |
| 63 | + padding: '12px 24px', |
| 64 | + backgroundColor: '$white', |
| 65 | + position: 'relative', |
| 66 | + color: '$black', |
| 67 | + borderRadius: '$1', |
| 68 | + cursor: 'pointer', |
| 69 | + transition: 'transform 250ms cubic-bezier(.2,.8,.4,1)' |
| 70 | +}); |
| 71 | + |
| 72 | +const cssStyling = ` |
| 73 | +.exampleClass { |
| 74 | + position: relative; |
| 75 | + padding: 1px; |
| 76 | + borderRadius: 8px; |
| 77 | +} |
| 78 | +
|
| 79 | +.exampleClass:hover div { |
| 80 | + transitionDuration: 0.25s; |
| 81 | + opacity: 1; |
| 82 | +} |
| 83 | +
|
| 84 | +.exmapleClass div { |
| 85 | + filter: blur(1px); |
| 86 | + borderRadius: 8px; |
| 87 | + position: absolute; |
| 88 | + top: 0px; |
| 89 | + left: 0px; |
| 90 | + width: 100%; |
| 91 | + height: 100%; |
| 92 | + transition: opacity 1.5s ease; |
| 93 | + background: 'linear-gradient(91.83deg, rgb(208, 60, 74) 2.26%, rgb(172, 74, 218) 95.81%)'; |
| 94 | + animation: 10s ease-in-out 0s infinite normal both running pulse; |
| 95 | + opacity: 0.75; |
| 96 | +} |
| 97 | +
|
| 98 | +.exampleClass span { |
| 99 | + padding: 12px 24px; |
| 100 | + backgroundColor: white; |
| 101 | + position: relative; |
| 102 | + color: black; |
| 103 | + borderRadius: 8px; |
| 104 | + cursor: pointer; |
| 105 | + transition: transform 250ms cubic-bezier(.2,.8,.4,1); |
| 106 | +} |
| 107 | +`; |
| 108 | + |
| 109 | +const scssStyling = ` |
| 110 | +.exampleClass { |
| 111 | + position: relative; |
| 112 | + padding: 1px; |
| 113 | + borderRadius: 8px; |
| 114 | +
|
| 115 | + &:hover div { |
| 116 | + transitionDuration: 0.25s; |
| 117 | + opacity: 1; |
| 118 | + } |
| 119 | +
|
| 120 | + div { |
| 121 | + filter: blur(1px); |
| 122 | + borderRadius: 8px; |
| 123 | + position: absolute; |
| 124 | + top: 0px; |
| 125 | + left: 0px; |
| 126 | + width: 100%; |
| 127 | + height: 100%; |
| 128 | + transition: opacity 1.5s ease; |
| 129 | + background: 'linear-gradient(91.83deg, rgb(208, 60, 74) 2.26%, rgb(172, 74, 218) 95.81%)'; |
| 130 | + animation: 10s ease-in-out 0s infinite normal both running pulse; |
| 131 | + opacity: 0.75; |
| 132 | + } |
| 133 | +
|
| 134 | + span { |
| 135 | + padding: 12px 24px; |
| 136 | + backgroundColor: white; |
| 137 | + position: relative; |
| 138 | + color: black; |
| 139 | + borderRadius: 8px; |
| 140 | + cursor: pointer; |
| 141 | + transition: transform 250ms cubic-bezier(.2,.8,.4,1); |
| 142 | + } |
| 143 | +} |
| 144 | +`; |
| 145 | + |
| 146 | +export { cssStyling, scssStyling, Component }; |
0 commit comments