It's very possible that I'm missing something and this is a terrible approach, but here goes nothing.
There is the is()
function in CSS that I like to take advantage of when trying to do some out of the box design work in Perspective. In this case, as a quick example, create two Styles one called "Blink_Trigger" and the other "Blink_Red". You don't need to set any attributes in these styles, you can just leave them empty. Then in your stylesheet resource add this:
:is(.psc-Blink_Trigger) .psc-Blink_Red {
background-color: red;
}
Paste this view into the project:
{
"custom": {},
"params": {},
"props": {
"defaultSize": {
"height": 529
}
},
"root": {
"children": [
{
"events": {
"component": {
"onRowClick": {
"config": {
"script": "\tif self.props.data[event.rowIndex].city.style.classes \u003d\u003d \"\":\n\t\tself.props.data[event.rowIndex].city.style.classes \u003d \"Blink_Red\"\n\t\tself.props.data[event.rowIndex].country.style.classes \u003d \"Blink_Red\"\n\t\tself.props.data[event.rowIndex].population.style.classes \u003d \"Blink_Red\"\n\telse:\n\t\tself.props.data[event.rowIndex].city.style.classes \u003d \"\"\n\t\tself.props.data[event.rowIndex].country.style.classes \u003d \"\"\n\t\tself.props.data[event.rowIndex].population.style.classes \u003d \"\"\n"
},
"scope": "G",
"type": "script"
}
}
},
"meta": {
"name": "Table"
},
"position": {
"height": 400,
"width": 652,
"x": 54,
"y": 42
},
"props": {
"data": [
{
"city": {
"align": "center",
"editable": true,
"justify": "left",
"style": {
"classes": ""
},
"value": "Folsom"
},
"country": {
"style": {
"classes": ""
},
"value": "United States"
},
"population": {
"style": {
"classes": ""
},
"value": 77271
}
},
{
"city": {
"align": "center",
"editable": true,
"justify": "left",
"style": {
"classes": "Blink_Red"
},
"value": "Folsom"
},
"country": {
"style": {
"classes": "Blink_Red"
},
"value": "United States"
},
"population": {
"style": {
"classes": "Blink_Red"
},
"value": 77271
}
},
{
"city": {
"align": "center",
"editable": true,
"justify": "left",
"style": {
"classes": ""
},
"value": "Folsom"
},
"country": {
"style": {
"classes": ""
},
"value": "United States"
},
"population": {
"style": {
"classes": ""
},
"value": 77271
}
},
{
"city": {
"align": "center",
"editable": true,
"justify": "left",
"style": {
"classes": ""
},
"value": "Folsom"
},
"country": {
"style": {
"classes": ""
},
"value": "United States"
},
"population": {
"style": {
"classes": ""
},
"value": 77271
}
},
{
"city": {
"align": "center",
"editable": true,
"justify": "left",
"style": {
"classes": "Blink_Red"
},
"value": "Folsom"
},
"country": {
"style": {
"classes": "Blink_Red"
},
"value": "United States"
},
"population": {
"style": {
"classes": "Blink_Red"
},
"value": 77271
}
}
],
"selection": {
"data": [
{
"city": "Folsom",
"country": "United States",
"population": 77271
}
],
"selectedColumn": "country",
"selectedRow": 2
}
},
"type": "ia.display.table"
}
],
"meta": {
"name": "root"
},
"propConfig": {
"props.style.classes": {
"binding": {
"config": {
"expression": "if(\n\tgetSecond(now(1000)) % 2,\n\t\"Blink_Trigger\",\n\t\"\"\n)"
},
"type": "expr"
}
}
},
"props": {
"style": {}
},
"type": "ia.container.coord"
}
}
This view has a binding on the root component's style.classes
property to swap the class between empty and Blink_Trigger
style class every second. This then results in the :is()
function in the stylesheet resource alternating between setting and unsetting the Blink_Red
style class background-color
attribute to red. I added a script to the table for clicking on the rows as a quick way of setting/removing the Blink_Red
class from each row to show that the color flashing remains in sync regardless of timing.
Unless I'm missing something, this shouldn't have a huge impact on the server since there is just the one expression that is having to make the round trip every second. The actual blinking is left up to CSS/your browser to handle the load - I wouldn't think this would be anything too crazy, but I'm far from a web browser expert...if someone knows that this will cause problems, please let me know and I'll gladly edit this post.
In the end, this example will look like this: