Skip to content

Instantly share code, notes, and snippets.

@gigaherz
Last active April 24, 2016 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigaherz/68abf8453b9f841ac4e07ea6300a7dcd to your computer and use it in GitHub Desktop.
Save gigaherz/68abf8453b9f841ac4e07ea6300a7dcd to your computer and use it in GitHub Desktop.
Thoughts on a semantic description for user interfaces, where the UI engine and theme decide the actual layout and controls used.

Semantic UI

Semantic UI represents a description of an user interface, in terms of 'what', and not 'how'.

Each element in the description consists of an identifier, a set of attributes, and a set of children.

##Syntax uses in the examples

The example syntax uses an indent-delimited format, with the character '#' indicating a comment until the end of the line. Multi-line comments start with '#[' and end with ']#', and nesting is allowed.

<Element> ::= <Identifier>(':' <Attribute>+)? (<Indent-in><Element>+<Indent-out>)?

<Identifier> ::= [A-Za-z][A-Za-z0-9_\-]*

<Attribute> ::= <Identifier> ('(' <Value-list> ')')?

<Value-list> ::= <Value> (',' <Value>)*

<Value> ::= {number}|{string literal}|{boolean literal}|<Identifier>

Attributes

  • Class: Defines the primary semantic meaning of the element. Only one is allowed.
    • Group: Declares a set of elements to be part of a grouping
      • Page: Group, to be displayed as a page
      • Screen: Group, to be displayed as a screen (would display inside the main window in windowed environments)
      • Window: Group, to be displayed as a floating window (in single-window or fullscreen environments, equivalent to Screen)
      • Dialog: Group, to be displayted as a popup window/panel that prevents using the controls behind it while open
    • Info: Declares an element that displays information
      • Label: Text, to be used as a label for the parent element
      • Message: Text, to be displayed as a popup dialog if the conditions are met
      • Header: Text, to be displayed as a group header
        • Title: Header
        • Subtitle: Header
    • Action: Declares an element to be interactable (button/hyperlink/menu item)
    • Choice: Declares an element
    • Toggle: Declares an element that can toggle on/off
    • Input: Declares an element that allows text input
    • Number: Declares an element that lets you input or choose a number
    • Date: Declares an element that lets you input or choose a date
    • Time: Declares an element that lets you input or choose a time
    • DateTime: Declares an element that lets you input or choose a date and time
    • Place: Declares an element that lets you input or choose a place
  • Limits: Declare the limits of the element. For Choice elements, this is the number of options that can be selected at once.
    • Min(int): Declares the minimum value that the element can accept
    • Max(int): Declares the maximum value that the element can accept
    • Range(int,int): Equivalent to Min and Max together
    • Single: Equivalent to Range(1,1)
  • Display: Hints for selecting display preferences
    • Priority(int): Declares the priority of the element. In situations of limited space, will be used to decide which elements to hide first. Negative numbers should be hidden by default even if there's space, unless the user chooses a "verbose" view mode.
    • Loose: Declares that the grouping or choice is preferred to not have a visual grouping delimiting the children from the element's siblings.
#[
This example describes a simple application window. The 'Window' attribute tells the UI engine this should be an independent/floating window, or the closest equivalent in the platform.
]#
Main-Window: Window
Tools: Group
File: Group
Open: Action
Save: Action
SaveAs: Action, Priority(-1) # Default priority is 0, items are given precedence based on priority, items with priority < 0 will not be shown by default on certain types of representations
Edit: Group
Cut: Action
Copy: Action
Paste: Action
Help: Group
About: Action
Style, Locale('en-US')
Element 'Tools/File/Open'
Text 'Open'
Image 'Open.png'
Element 'Tools/File/Save'
Text 'Save'
Image 'Save.png'
Element 'Tools/File/SaveAs'
Text 'Save As'
Image 'SaveAs.png'
Options: Dialog
General: Group
Localization: Group
Language: Choice, Single # Single is equivalent to: Range(1, 1)
English
Spanish
Catalan
French
German
Italian
Toolbar: Group
Hide: Boolean
Icon-Size: Choice, Single, Loose # Loose hints the semantic engine that it's not expected to generate a visual grouping for the elements
Small
Large
Default
Menubar: Group
Hide: Boolean
Document-Switcher: Group
Show: Boolean
Tabstrip: Group
Hide: Boolean
Multi-Line: Boolean
Vertical: Boolean
Compact: Boolean
Lock: Boolean
Darken-Inactive: Boolean
Mark-Active: Boolean
Show-Close-Button-In-Tabs: Boolean
Double-Click-To-Close: Boolean
Status-Bar: Group
Show: Boolean
Edit: Group
Cursor: Group
Width: Choice, Single
0
1
2
3
Block
Frequency: Integer, Range(1, 100)
Multi-Edit: Group
Enable: Boolean
Bullet-Style: Choice, Single
Simple
Arrows
Circles
Squares
None
Line-Length-Marker: Group
Mode: Choice, Single, Loose
None
Line
Background
Columns: Integer, Min(1)
Border: Group
Thickness: Integer, Range(1, 32)
Line-Adjust: Choice, Single
Default
Aligned
Tabulated
Line-Numbers: Boolean
Markers: Boolean
Mark-Active-Line: Boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment