frc-nt-svelte
v0.1.4
Published
  ];
$matchNumber: number;Grid
All built in components support a Shuffleboard style grid system for quick UI development. The grid is configurable size, with defaults of 12 columns, 5 rows. This can be changed with the rows or columns properties on the Grid component.
Pass in the rowSpan or colSpan props on components to change how wide or tall the components are.
Theming
Currently, all theming is done through CSS variables. There are no default values, so they need to be set manually.
:root {
--true-boolean: green;
--false-boolean: red;
}Custom components
The NetworkTables API is exposed for use in custom components. This uses the pynetworktables2js API, documented at https://robotpy.readthedocs.io/projects/pynetworktables2js/en/stable/api_js.html. The NetworkTables variable can be found by using import { NetworkTables } from "frc-nt-svelte";
If you want your component to have the same grid capabilities as the built in components, wrap it in a GridItem and pass in a colSpan and rowSpan variable.
Sample component (BooleanIndicator)
<script>
import NetworkTables from "./utils/networktables";
import { onMount } from "svelte";
import GridItem from "./grid/GridItem.svelte";
let value = false;
export let ntKey;
export let rowSpan = 1;
export let colSpan = 1;
onMount(() => {
NetworkTables.addKeyListener(
ntKey,
(key, data, isNew) => {
value = data;
},
true
);
});
</script>
<GridItem {colSpan} {rowSpan}>
<div class="indicator" class:true={value}>
<slot />
</div>
</GridItem>
<style>
.indicator {
background-color: var(--false-boolean);
padding: 20px;
width: 100%;
height: 100%;
}
.true {
background-color: var(--true-boolean);
}
</style>