视频分析

1.mp4 (44.08MB)

源文件

Card.framerx.zip

代码

  1. import * as React from "react"
  2. import { Frame, addPropertyControls, ControlType } from "framer"
  3. import styled from "styled-components" //这个需要通过npm或者yarn安装
  4. // Open Preview: Command + P
  5. // Learn more: https://framer.com/api
  6. const CardContent = styled.div`
  7. width:${props => props.width}px;
  8. height:${props => props.height}px;
  9. background-color:${props => props.background};
  10. border-radius:${props => props.radius}px;
  11. box-shadow:0px ${props => props.y}px ${props => props.b}px ${props =>
  12. props.s}px ${props => props.shadowColor};
  13. color:white;
  14. font-size:12px;
  15. font-weight:600;
  16. text-align:center;
  17. padding-top:24px
  18. `
  19. export function Card(props) {
  20. //这里可以修改阴影的百分比
  21. const radius = Math.ceil(props.width * 0.04)
  22. const y = Math.ceil(props.height * 0.2)
  23. const b = Math.ceil(props.height * 0.5)
  24. const s = Math.ceil(-props.height * 0.15)
  25. return (
  26. <CardContent
  27. width={props.width}
  28. height={props.height}
  29. background={props.background}
  30. radius={radius}
  31. y={y}
  32. b={b}
  33. s={s}
  34. shadowColor={props.shadowColor}
  35. >
  36. <Frame background={""} visible={props.showText} height={20} center>
  37. r:{radius} &nbsp;&nbsp; y: {y}&nbsp;&nbsp; b: {b}&nbsp;&nbsp; s:{" "}
  38. {s}{" "}
  39. </Frame>
  40. </CardContent>
  41. )
  42. }
  43. Card.defaultProps = {
  44. height: 128,
  45. width: 240,
  46. text: "Get started!",
  47. background: "rgb(25, 96, 255)",
  48. mark: true,
  49. }
  50. // Learn more: https://framer.com/api/property-controls/
  51. addPropertyControls(Card, {
  52. background: {
  53. title: "background",
  54. type: ControlType.Color,
  55. defaultValue: "rgb(25, 96, 255)",
  56. },
  57. shadowColor: {
  58. title: "shadowColor",
  59. type: ControlType.Color,
  60. defaultValue: "rgba(25, 96, 255,0.5)",
  61. },
  62. showText: {
  63. title: "showText",
  64. type: ControlType.Boolean,
  65. enabledTitle: "Show",
  66. disabledTitle: "Hide",
  67. },
  68. })