Skip to content

Instantly share code, notes, and snippets.

@scotje
Last active June 20, 2024 21:44
Show Gist options
  • Save scotje/04d283bb34eefac92749357e1e47640d to your computer and use it in GitHub Desktop.
Save scotje/04d283bb34eefac92749357e1e47640d to your computer and use it in GitHub Desktop.

Stamp Template

Open Questions

  • Do fields need optional "label" attribute that can be customized at the Template level?
  • Can filled_text or multiple_choice fields be marked as optional in the Template?

Structure

Proposed database fields:

  • Name
  • Creator
  • Created At
  • Updated At
  • Last Used At
  • Stamp Template Meta

[other things?]

Stamp Template Meta

The Stamp Template Meta will be represented in the database as a JSON object consisting of two top-level keys: format and fields.

See the details below but here is a full example of what a Template Meta might look like:

{
  "format": {
    "stroke": { "r": 0, "g": 0, "b": 0, "a": 1.0 },
    "fill": { "r": 0, "g": 0, "b": 0, "a": 1.0 },
    "rx": 0,
    "ry": 0
  },
  "fields": [
    {
      "name": "Company Name",
      "type": "auto_populated_text",
      "variant": "company_name",
      "format": {}
    },
    {
      "name": "Stamp Title",
      "type": "static_text",
      "value": "Submittal Review",
      "format": {}
    },
    {
      "name": "Approval Status",
      "type": "multiple_choice",
      "options": [
        { "value": "Approved" },
        { "value": "Approved w/ Comments" },
        { "value": "Rejected" }
      ],
      "format": {}
    },
    {
      "name": "Comments",
      "type": "filled_text",
      "value": null,
      "format": {}
    },
    {
      "name": "Approver and Time Stamp",
      "type": "auto_populated_text",
      "variant": "approver_with_timestamp",
      "format": {}
    },
    {
      "name": "Legal Disclosure",
      "type": "filled_text",
      "value": "Neither Party makes any representation or warranty regarding the accuracy or completeness of, or absence of defects in, the Proprietary Information disclosed hereunder, or with respect to infringement of any rights, including intellectual property rights of others, arising from its disclosure of Proprietary Information hereunder.",
      "format": {}
    }
  ]
}

format

JSON blob of formatting information that is global to the entire Template. According to Figma designs, the examples of things that can be customized are:

  • Border Color (stroke?)
  • Stamp Color (fill?)
  • Background Opacity (fill alpha?)
  • Stamp Shape (rect or round rect)
  • Padding? (maybe hard coded for now?)

Example:

{
  "stroke": { "r": 0, "g": 0, "b": 0, "a": 1.0 },
  "fill": { "r": 0, "g": 0, "b": 0, "a": 1.0 },
  "rx": 0,
  "ry": 0
}

(In this example, stroke and fill are just serialized instances of AV2F's AnnotationColorJson class.)

fields

The contents of fields is the core of the Template. This array is what defines which of the pre-defined fields exist in the Template and in what order.

There are initially four distinct "types" of fields:

  • Auto Populated
  • Static Text
  • Filled Text
  • Multiple-Choice

Auto Populated

Field value is generated automatically when the Stamp is created in a document. Users cannot modify or alter these values.

Example:

{
  "name": "Company Name",
  "type": "auto_populated_text",
  "variant": "company_name",
  "format": {
    "textParams": {}
  }
}

Static Text

Field whose value can be set when the Template is created but cannot be modified during Stamp creation.

Example:

{
  "name": "Stamp Title",
  "type": "static_text",
  "value": "Submittal Review",
  "format": {
    "textParams": {}
  }
}

Filled Text

Field whose value can be supplied by the user during Stamp creation, with optional default.

Note: For this field type, value represents the default or placeholder value but the user can modify this during Stamp creation.

Example:

{
  "name": "Legal Disclosure",
  "type": "filled_text",
  "value": "Neither Party makes any representation or warranty regarding the accuracy or completeness of, or absence of defects in, the Proprietary Information disclosed hereunder, or with respect to infringement of any rights, including intellectual property rights of others, arising from its disclosure of Proprietary Information hereunder.",
  "format": {
    "textParams": {}
  }  
}

Multiple Choice (Enum?)

Field with a limited set of possible values which are defined during template creation. User must select one of the available options during Stamp creation.

Example:

{
  "name": "Approval Status",
  "type": "multiple_choice",
  "options": [
    { "value": "Approved" },
    { "value": "Approved w/ Comments" },
    { "value": "Rejected" }
  ],
  "format": {
    "textParams": {}
  }  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment