Skip to content

Commit f6f2015

Browse files
committed
Updated articles in the Cards section
1 parent 3ec4503 commit f6f2015

File tree

3 files changed

+91
-42
lines changed

3 files changed

+91
-42
lines changed
Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,103 @@
11
---
2-
description: Configuring count cards in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Learn how to configure count cards in Umbraco UI Builder.
33
---
44

55
# Count Cards
66

7-
Count cards allow you to define cards directly against the [collection](../collections/overview.md) configuration, providing a basic **where clause** to use in a count SQL statement. These work perfectly for basic data visualizations based on counts of entities in a collection.
7+
Count cards allow you to define cards directly against the [Collection](../collections/overview.md) configuration, providing a basic **where clause** to use in a count SQL statement. These work perfectly for basic data visualizations based on counts of entities in a collection.
88

9-
If you need to do more than a basic count, you'll want to take a look at the [custom cards](custom-cards.md) documentation.
9+
If you need to do more than a basic count, see the [Custom Cards](custom-cards.md) article.
1010

11-
## Adding a count card to a collection
11+
## Adding a Count Card to a Collection
1212

13-
Cards allow you to display basic summaries of key information that may be useful to the editor.
13+
Count cards display basic summaries of key information that may be useful to the editor.
1414

15-
### **AddCard(string name, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder**
15+
### Using the `AddCard()` Method
1616

17-
Adds a card with the given name and **where clause** filter expression. Expression must be a `boolean` expression.
17+
Adds a count card with the specified name and a where clause filter expression. The filter expression must be a `boolean` value.
18+
19+
#### Method Syntax
20+
21+
```cs
22+
AddCard(string name, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder
23+
```
24+
25+
#### Example
1826

1927
````csharp
20-
// Example
2128
collectionConfig.AddCard("Older than 30", p => p.Age > 30, cardConfig => {
2229
...
2330
});
2431
````
2532

26-
### **AddCard(string name, string icon, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder**
33+
### Using the `AddCard()` Method with Icon
34+
35+
Adds a count card with the specified name, an icon, and a where clause filter expression. The filter expression must be a `boolean` value.
2736

28-
Adds a card with the given name + icon and **where clause** filter expression. Expression must be a `boolean` expression.
37+
#### Method Syntax
38+
39+
```cs
40+
AddCard(string name, string icon, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder
41+
```
42+
43+
#### Example
2944

3045
````csharp
31-
// Example
3246
collectionConfig.AddCard("Older than 30", "icon-umb-users", p => p.Age > 30, cardConfig => {
3347
...
3448
});
3549
````
3650

37-
### Change the color of a count card
51+
### Change the Color of a Count Card
52+
53+
#### Using the `SetColor()` Method
54+
55+
Sets the color for the count card.
3856

39-
#### **SetColor(string color) : CardConfigBuilder**
57+
#### Method Syntax
4058

41-
Sets the color of the card.
59+
```cs
60+
SetColor(string color) : CardConfigBuilder
61+
```
62+
63+
#### Example
4264

4365
````csharp
44-
// Example
4566
cardConfig.SetColor("blue");
4667
````
4768

48-
### Add a suffix to a count value
69+
### Add a Suffix to a Count Value
70+
71+
#### Using the `SetSuffix()` Method
72+
73+
Sets a suffix to be displayed alongside the card value.d
74+
75+
#### Method Syntax
4976

50-
#### **SetSuffix(string suffix) : CardConfigBuilder**
77+
```cs
78+
SetSuffix(string suffix) : CardConfigBuilder
79+
```
5180

52-
Sets the suffix of the card value.
81+
#### Example
5382

5483
````csharp
55-
// Example
5684
cardConfig.SetSuffix("years");
5785
````
5886

59-
### Formatting the value of a count
87+
### Formatting the Value of a Count
88+
89+
#### Using the `SetFormat()` Method
90+
91+
Sets a custom format for the card's value.
92+
93+
#### Method Syntax
6094

61-
#### **SetFormat(Lambda formatExpression) : CardConfigBuilder**
95+
```cs
96+
SetFormat(Lambda formatExpression) : CardConfigBuilder
97+
```
6298

63-
Sets the format expression for the card.
99+
#### Example
64100

65101
````csharp
66-
// Example
67102
cardConfig.SetFormat((v) => $"{v}%");
68103
````
Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
description: Configuring custom cards in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Learn how to configure custom cards in Umbraco UI Builder.
33
---
44

55
# Custom Cards
66

7-
Custom cards allow you to perform more complex metric calculations and are defined via a class implementing the `Card` base class.
7+
Custom cards enable more complex metric calculations and are defined by a class that implements the `Card` base class.
88

9-
When Umbraco UI Builder resolves a card it will attempt to do so from the global DI container. This means you can inject any dependencies that you require for your card to calculate its value. If there is no type defined in the DI container, Umbraco UI Builder will fall-back to manually instantiating a new instance of value mapper.
9+
When Umbraco UI Builder resolves a card, it tries to do so from the global DI container. This means you can inject any dependencies required for the card's value calculation. If no type is found in the DI container, Umbraco UI Builder will fall back to manually instantiating a new instance of the value mapper.
1010

11-
## Defining a custom card
11+
## Defining a Custom Card
1212

13-
To define a card you create a class that inherits from the base class `Card` and configure it within the constructor like so.
13+
To define a custom card, create a class that inherits from the base class `Card` and configure it in the constructor as shown below:
1414

1515
````csharp
1616
// Example
@@ -33,30 +33,44 @@ The required configuration options are:
3333

3434
* **Name:** The name of the card.
3535
* **Alias:** A unique alias for the card.
36-
* **GetValue(object parentId = null):** A method to get the cards value.
36+
* **GetValue(object parentId = null):** A method to retrieve the card's value.
3737

38-
Additional optional configuration options are:
38+
The optional configuration options are:
3939

40-
* **Icon:** An icon to display in the card.
40+
* **Icon:** An icon displaed in the card.
4141
* **Color:** The color of the card.
42-
* **Suffix:** A suffix to display after the card value.
42+
* **Suffix:** The suffix displayed after the card value.
4343

44-
## Adding a custom card to a collection
44+
## Adding a Custom Card to a Collection
4545

46-
### **AddCard<TCardType>() : CollectionConfigBuilder&lt;TEntityType&gt;**
46+
### Using the `AddCard()` Method
4747

48-
Adds a card of the given type to the collection.
48+
Adds a custom card of the specified type to the collection.
49+
50+
#### Method Syntax
51+
52+
```cs
53+
AddCard() : CollectionConfigBuilder<TEntityType>
54+
```
55+
56+
#### Example
4957

5058
````csharp
51-
// Example
5259
collectionConfig.AddCard<AvgPersonAgeCard>();
5360
````
5461

55-
### **AddCard(Type cardType) : CollectionConfigBuilder&lt;TEntityType&gt;**
62+
### Using the `AddCard(Type cardType)` Method
5663

57-
Adds a card of the given type to the collection.
64+
Adds a custom card of the specified type to the collection, using the `Type` parameter to pass the card type dynamically.
65+
66+
#### Method Syntax
67+
68+
```cs
69+
AddCard(Type cardType) : CollectionConfigBuilder<TEntityType>
70+
```
71+
72+
#### Example
5873

5974
````csharp
60-
// Example
6175
collectionConfig.AddCard(typeof(AvgPersonAgeCard));
6276
````

15/umbraco-ui-builder/cards/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
description: Configuring cards in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Learn how to configure cards in Umbraco UI Builder.
33
---
44

55
# Cards
66

7-
Cards provide an API to display basic summary information in a card-based format and are useful for displaying key metrics about a collection.
7+
Cards provide an API to display summary information in a card-based format, which is useful for displaying key metrics about a collection.
88

99
![Cards](../images/cards.png)
1010

11-
Cards can be defined in one of two ways:
11+
Cards can be defined in two ways:
1212

1313
{% content-ref url="count-cards.md" %}
1414
[Count Cards](count-cards.md)

0 commit comments

Comments
 (0)