designSystemSection function

String designSystemSection(
  1. DesignSystem ds, {
  2. bool docsTool = true,
})

The section of the base for ds: its principles in brief, its tokens by name, its components (each with its purpose, parameters, slots, events and a minimal call) and its patterns in brief.

Implementation

String designSystemSection(DesignSystem ds, {bool docsTool = true}) {
  final b = StringBuffer()
    ..writeln('## The design system: ${ds.name}')
    ..writeln()
    ..writeln('Every UI you make is in ${ds.name}${ds.manifest.description.isEmpty ? '' : ': ${ds.manifest.description.replaceFirst(RegExp(r'[.\s]+$'), '')}'}. '
        'Compose it from its components (below) and the layout nodes (`column`, `row`, `stack`, `text`, `icon`, `box`); '
        'style it with its tokens by name. Its components carry its look: do not restyle them, and do not draw a control '
        'yourself when a component is one.')
    ..writeln();
  final principles = _brief(ds.design);
  if (principles.isNotEmpty) {
    b
      ..writeln('### Principles')
      ..writeln()
      ..writeln(principles)
      ..writeln();
  }
  b
    ..writeln('### Tokens')
    ..writeln()
    ..writeln(_tokens(ds.tokens))
    ..writeln()
    ..writeln('### Components')
    ..writeln()
    ..writeln('Call one with a node whose `type` is its name: its parameters in `props` (or bound, `"bind": {"props.label": '
        '"\${item.name}"}`), slot content by id in `slots`, the call\'s `layout` sizing it (a call takes no `decoration`). '
        'Its events are handled by reactions on the call, `{"trigger": {"type": "event", "event": "onPressed"}, "actions": '
        '[...]}`, the value in `\${result}`. A `variable` parameter takes the name of one of your variables and keeps it '
        'in step (two-way).')
    ..writeln();
  for (final c in ds.list) {
    b.writeln(_component(c));
  }
  final patterns = _brief(ds.patterns);
  if (patterns.isNotEmpty) {
    b
      ..writeln()
      ..writeln('### Patterns')
      ..writeln()
      ..writeln(patterns);
  }
  if (docsTool) {
    b
      ..writeln()
      ..writeln('More: ui_docs "design" (the principles in full), "patterns" (every pattern), or a component\'s name (all its '
          'parameters).');
  }
  return b.toString().trimRight();
}