1
0

star.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from nicegui import ui
  2. from nicegui.element import Element
  3. from website import svg
  4. STYLE = '''
  5. @keyframes star-tumble {
  6. 0% { transform: translateX(6em) rotate(432deg); }
  7. 100% { transform: translateX(0) rotate(0); }
  8. }
  9. @keyframes star-pulse {
  10. 0% { scale: 1.0; }
  11. 60% { scale: 1.0; }
  12. 70% { scale: 1.2; }
  13. 80% { scale: 1.0; }
  14. 90% { scale: 1.2; }
  15. 100% { scale: 1.0; }
  16. }
  17. .star {
  18. height: 1.75em;
  19. fill: white;
  20. animation: 1s ease-in-out 6s both star-tumble,
  21. 3s ease-in-out 3s infinite star-pulse;
  22. }
  23. .star:hover {
  24. fill: rgb(250, 204, 21);
  25. }
  26. @keyframes star-grow {
  27. 0% { width: 0 }
  28. 100% { width: 2em }
  29. }
  30. .star-container {
  31. animation: 1s ease-in-out 6s both star-grow;
  32. }
  33. '''
  34. STAR = '''
  35. <svg viewBox="0 0 16 16">
  36. <path d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path>
  37. </svg>
  38. '''
  39. def add_star() -> ui.link:
  40. ui.add_css(STYLE)
  41. with ui.link(target='https://github.com/zauberzeug/nicegui/').classes('star-container') as link:
  42. with Element('svg').props('viewBox="0 0 24 24"').classes('star'):
  43. Element('path').props('d="M23.555,8.729a1.505,1.505,0,0,0-1.406-.98H16.062a.5.5,0,0,1-.472-.334L13.405,1.222a1.5,1.5,0,0,0-2.81,0l-.005.016L8.41,7.415a.5.5,0,0,1-.471.334H1.85A1.5,1.5,0,0,0,.887,10.4l5.184,4.3a.5.5,0,0,1,.155.543L4.048,21.774a1.5,1.5,0,0,0,2.31,1.684l5.346-3.92a.5.5,0,0,1,.591,0l5.344,3.919a1.5,1.5,0,0,0,2.312-1.683l-2.178-6.535a.5.5,0,0,1,.155-.543l5.194-4.306A1.5,1.5,0,0,0,23.555,8.729Z"')
  44. with ui.tooltip('').classes('bg-[#486991] w-96 p-4'):
  45. with ui.row().classes('items-center no-wrap'):
  46. svg.face().classes('w-14 stroke-white stroke-[1pt]')
  47. with ui.column().classes('p-2 gap-2'):
  48. ui.label('Star us on GitHub!').classes('text-[180%]')
  49. ui.label('And tell others about NiceGUI.').classes('text-[140%]')
  50. return link