Ir al contenido

Tarjetas ​

Traducción automática

Esta página se tradujo automáticamente del inglés y todavía no la revisó un hablante nativo; las correcciones son bienvenidas en GitHub. Si algo no coincide, vale el original en inglés.

Tarea: mostrar algunos elementos lado a lado, cada uno en su propia caja.

yaml
# Recipe: cards with a header, a body and a footer, in a grid.
paths:
  components: ./components

ui:card contiene un ui:card-header, un ui:card-body y un ui:card-footer, todos opcionales. ui:grid columns="3" distribuye las tarjetas en tres columnas. Una tarjeta con solo un título y algo de texto no necesita partes: basta con title=.

xml
<q:component name="Plans">
  <q:set name="plans" type="array"
         value='[{"name": "Free", "price": 0, "seats": 1}, {"name": "Team", "price": 12, "seats": 10}, {"name": "Company", "price": 40, "seats": 100}]' />

  <ui:window title="Plans">
    <!-- Three columns; the grid wraps on a narrow screen. -->
    <ui:grid columns="3" gap="md" padding="lg">
      <q:loop type="array" var="plan" items="{plans}">
        <ui:card>
          <ui:card-header>
            <ui:text weight="bold">{plan.name}</ui:text>
          </ui:card-header>
          <ui:card-body>
            <ui:text>${plan.price} a month</ui:text>
            <ui:text>Up to {plan.seats} people</ui:text>
          </ui:card-body>
          <ui:card-footer>
            <ui:link to="/signup?plan={plan.name}">Choose {plan.name}</ui:link>
          </ui:card-footer>
        </ui:card>
      </q:loop>
    </ui:grid>
    <!-- A card with only a title and text needs no parts. -->
    <ui:card title="Not sure?" padding="lg">
      <ui:text>Every plan starts with 30 free days.</ui:text>
    </ui:card>
  </ui:window>
</q:component>
xml
<q:test name="one card per plan, with its three parts" page="/">
  <test:visit />
  <test:expect text="Free $0 a month Up to 1 people Choose Free" />
  <test:expect text="Company $40 a month Up to 100 people Choose Company" />
</q:test>

<q:test name="a card with a title only" page="/">
  <test:visit />
  <test:expect text="Not sure? Every plan starts with 30 free days." />
</q:test>
text
tests/cards.test.q
  PASS  one card per plan, with its three parts
  PASS  a card with a title only
2 passed, 0 failed

Ver UI-7.

Licencia MIT · Hecho con VitePress