aboutsummaryrefslogtreecommitdiff
path: root/luax/components/project.luax
blob: ddb8c69d2253f8b38b98fd405b394ed5fe1e9654 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
local Carousel = require('components.carousel')

function getProjectImageLink(project, image)
  return 'assets/' .. project.type .. 's/' .. project.name_normalized .. '/' .. image
end

function getProjectTechIconLink(tech)
  return 'assets/images/' .. tech .. '.png'
end

function getProjectTargetIconLink(target)
  return 'assets/images/' .. target .. '.png'
end

return function (props)
  local project = props.attrs.project
  local techs = {}
  for _, tech in ipairs(project.tech) do
    techs[#techs + 1] = <img class="grow icon" src={getProjectTechIconLink(tech)} />
  end
  local targets = {}
  for _, target in ipairs(project.targets) do
    targets[#targets + 1] = <img class="grow icon" src={getProjectTargetIconLink(target)} />
  end

  local images = nil
  if project.images then
    images = {}
    for _, image in ipairs(project.images) do
      images[#images + 1] = <img class="carousel-item" src={getProjectImageLink(project, image)} />
    end

    images = <Carousel>{$ images $}</Carousel>
  end

  return (
    <div class="project">
      <div class="project-title"><a href={project.link}>{$ project.name $}</a></div>
      <div class="project-info">
        <div class="icon-row">
          <div class="icon-text">Made using</div>
          <div class="icon-container">
            {$ techs $}
          </div>
        </div>
        <div class="icon-row">
          <div class="icon-text">Available on</div>
          <div class="icon-container">
            {$ targets $}
          </div>
        </div>
        <hr />
        <div class="project-description">
          {$ project.description $}
        </div>
      </div>
      {$ images $}
    </div>
  )
end