Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

deck.ts 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /// <reference path="../../external/react/react.d.ts"/>
  2. module rpgcards {
  3. export interface DeckTileProps extends React.Props<any> {
  4. key : string; //< Unique key for react
  5. id : string;
  6. name : string;
  7. desc : string;
  8. }
  9. function DeckTilePropsEqual(a:DeckTileProps, b:DeckTileProps) {
  10. return a.id === b.id &&
  11. a.name === b.name &&
  12. a.desc === b.desc;
  13. }
  14. interface DeckTileState {
  15. }
  16. export function tileHeader(props: DeckTileProps): React.ReactElement<any> {
  17. return React.DOM.div
  18. ( { className: 'deck-tile-header', onClick: null }
  19. , props.name
  20. );
  21. }
  22. export function tileBody(props: DeckTileProps): React.ReactElement<any> {
  23. return React.DOM.div
  24. ( { className: 'deck-tile-body', onClick: null }
  25. , React.DOM.p(null, props.desc)
  26. );
  27. }
  28. export function tileFooter(props: DeckTileProps): React.ReactElement<any> {
  29. return null;
  30. }
  31. export class DeckTileSpec extends React.Component<DeckTileProps, DeckTileState> {
  32. displayName: string;
  33. initialState(props: DeckTileProps): DeckTileState {
  34. return {};
  35. }
  36. // Use this function to speed up rendering
  37. /*
  38. shouldComponentUpdate(nextProps: DeckTileProps, nextState: DeckTileState): boolean {
  39. return DeckTilePropsEqual(this.props, nextProps);
  40. }
  41. */
  42. constructor(props: DeckTileProps) {
  43. super(props);
  44. this.state = this.initialState(props);
  45. this.displayName = "DeckTile";
  46. }
  47. render() {
  48. return React.DOM.div( { className: 'deck-tile' }
  49. , React.DOM.div( { className: 'deck-tile-content' }
  50. , tileHeader(this.props)
  51. , tileBody(this.props)
  52. , tileFooter(this.props)
  53. ));
  54. }
  55. }
  56. export var DeckTile: React.Factory<DeckTileProps> = React.createFactory(DeckTileSpec);
  57. }