Star.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React from 'react'
  21. import { IStar, IEvent, IStarUserList } from './types'
  22. const styles = require('./Star.less')
  23. import StarUser from './StarUser'
  24. function stopPPG(e: IEvent) {
  25. e.stopPropagation()
  26. }
  27. const Star: React.FC<IStar> & {
  28. StarUser: React.FC<IStarUserList>
  29. } = ({ proId, isStar, unStar, starNum, userList }) => {
  30. return (
  31. <div className={styles.starWrapper} onClick={stopPPG}>
  32. <span onClick={stopPPG}>
  33. <span className={styles.leftWrapper} onClick={unStar(proId)}>
  34. <span
  35. className={`iconfont ${isStar ? 'icon-star1' : 'icon-star'}`}
  36. style={{ fontSize: '12px' }}
  37. />
  38. &nbsp;
  39. <span>{isStar ? 'Unstar' : 'star'}</span>
  40. </span>
  41. </span>
  42. <span>
  43. <span className={styles.starCount} onClick={userList(proId)}>
  44. {starNum}
  45. </span>
  46. </span>
  47. </div>
  48. )
  49. }
  50. Star.StarUser = StarUser
  51. export default Star