1
0
Fork 0
freesewing/sites/shared/components/animations/freesewing.mjs

175 lines
4.6 KiB
JavaScript
Raw Normal View History

2023-07-28 20:28:27 +02:00
import { logoPath } from 'shared/components/logos/freesewing.mjs'
import { useTranslation } from 'next-i18next'
export const ns = ['commom']
2023-07-29 11:02:25 +02:00
const strokeScale = 0.7
const StrokedText = (props) => (
<>
<text
{...props}
strokeWidth={Number(props.strokeWidth) / 2}
stroke="hsl(var(--b1))"
fill="none"
/>
<text {...props} />
</>
)
export const FreeSewingAnimation = ({
className = 'w-full', // Any classes to set on the SVG tag
stroke = 1, // The stroke width of the initial colouring in of the logo
duration = 10, // Duration of the complete animation in seconds
}) => {
2023-07-28 20:28:27 +02:00
const { t } = useTranslation(ns)
2023-07-29 11:02:25 +02:00
// Ensure duration is a number
duration = Number(duration)
// Ensure stroke is a number
stroke = Number(stroke) * strokeScale
2023-07-28 20:28:27 +02:00
return (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
2023-07-29 11:02:25 +02:00
viewBox="-1 0 27 27"
2023-07-28 20:28:27 +02:00
strokeWidth={stroke}
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
className={className + ' icon'}
>
<animat
attributeName="viewBox"
from="0 0 25 25"
to="0 10 25 7"
2023-07-29 11:02:25 +02:00
begin={`${duration * 0.18}s`}
dur={`${duration * 0.03}s`}
2023-07-28 20:28:27 +02:00
fill="freeze"
/>
<clipPath id="logo">
<path d={logoPath} stroke="none" fill="none" transform="translate(-0.5,0)" />
</clipPath>
<g>
<g>
<path
d="M 20 0 l -10,1 l 10 1 l -11 1 l 13 1 l -15 1 l 16 1 l -16 1 l 15 1 l -15 1 l 16 1 l -16 1 l 17 1 l-16 1 l15 1 l -18 1.3 l 19 0.2 l -15 1 l 6 0.5 l -5 0.5 l 5 0 l 9 -0.5 l -3 1.2 l 2 1 l -3 0 l 2 2 l -3 -0.5 l 1 2 l -3 -1 l1 2 l-3 -1 l -1.5 1.5 l-2 -1.5 l-3 1 l-5 -7 l 2 -2 l-3 -1 l 2 -2"
clipPath="url(#logo)"
strokeOpacity="1"
strokeDasharray="330 400"
>
2023-07-29 11:02:25 +02:00
<animate
attributeName="stroke-dashoffset"
dur={`${duration * 0.333}s`}
from="330"
to="0"
fill="freeze"
/>
2023-07-28 20:28:27 +02:00
<animate
attributeName="stroke-width"
2023-07-29 11:02:25 +02:00
begin={`${duration * 0.333}s`}
dur={`${duration * 0.05}s`}
from={stroke}
2023-07-28 20:28:27 +02:00
to="3"
fill="freeze"
/>
2023-07-29 11:02:25 +02:00
<animateTransfor
2023-07-28 20:28:27 +02:00
attributeName="transform"
attributeType="XLM"
type="scale"
2023-07-29 11:02:25 +02:00
begin={`${duration * 0.433}s`}
dur={`${duration * 0.1}s`}
2023-07-28 20:28:27 +02:00
from="1"
2023-07-29 11:02:25 +02:00
to="0.45"
2023-07-28 20:28:27 +02:00
fill="freeze"
/>
</path>
2023-07-29 11:02:25 +02:00
<animateTransfor
2023-07-28 20:28:27 +02:00
attributeName="transform"
attributeType="XLM"
type="translate"
2023-07-29 11:02:25 +02:00
begin={`${duration * 0.433}s`}
dur={`${duration * 0.1}s`}
2023-07-28 20:28:27 +02:00
from="0,0"
2023-07-29 11:02:25 +02:00
to="6.5,0"
2023-07-28 20:28:27 +02:00
fill="freeze"
/>
</g>
2023-07-29 11:02:25 +02:00
<StrokedText
2023-07-28 20:28:27 +02:00
x="12.5"
2023-07-29 11:02:25 +02:00
y="23"
strokeWidth={stroke}
2023-07-28 20:28:27 +02:00
stroke="none"
2023-07-29 11:02:25 +02:00
fill="hsl(var(--p))"
2023-07-28 20:28:27 +02:00
textAnchor="middle"
opacity="0"
style={{
fontSize: 4.2,
fontWeight: 'bold',
letterSpacing: '-0.007rem',
}}
>
FreeSewing
2023-07-29 11:02:25 +02:00
<animate
attributeName="opacity"
begin={`${duration * 0.45}s`}
dur={`${duration * 0.1}s`}
from="0"
to="1"
fill="freeze"
/>
</StrokedText>
<StrokedText
x="1.666"
y="24.5"
2023-07-28 20:28:27 +02:00
stroke="none"
2023-07-29 11:02:25 +02:00
strokeWidth={stroke}
fill="hsl(var(--s))"
textAnchor="start"
2023-07-28 20:28:27 +02:00
opacity="0"
style={{
fontSize: 1.4,
fontWeight: 'bold',
letterSpacing: '-0.005rem',
}}
>
{t('common:slogan1')}
2023-07-29 11:02:25 +02:00
<animate
attributeName="opacity"
begin={`${duration * 0.6}s`}
dur={`${duration * 0.05}s`}
from="0"
to="1"
fill="freeze"
/>
</StrokedText>
<StrokedText
x="23.333"
y="26"
2023-07-28 20:28:27 +02:00
stroke="none"
2023-07-29 11:02:25 +02:00
strokeWidth={stroke}
fill="hsl(var(--a))"
textAnchor="end"
2023-07-28 20:28:27 +02:00
opacity="0"
style={{
fontSize: 1.4,
fontWeight: 'bold',
letterSpacing: '-0.005rem',
}}
>
{t('common:slogan2')}
2023-07-29 11:02:25 +02:00
<animate
attributeName="opacity"
begin={`${duration * 0.7}s`}
dur={`${duration * 0.05}s`}
from="0"
to="1"
fill="freeze"
/>
</StrokedText>
2023-07-28 20:28:27 +02:00
</g>
</svg>
)
}