diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/cheerio.test.ts b/packages/ripple-tide-api/src/utils/markup-transpiler/cheerio.test.ts index 70c0c026f1..efe429a73b 100644 --- a/packages/ripple-tide-api/src/utils/markup-transpiler/cheerio.test.ts +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/cheerio.test.ts @@ -16,6 +16,7 @@ const markup = { image: `
Image
`, button: `Button`, link: `Link`, + list: `
  1. List item
  1. List item
  1. List item
  1. List item
`, iframe: `` } @@ -68,6 +69,7 @@ const fixed = { image: `
Image
`, button: `Button`, link: `Link(opens in a new window)`, + list: `
  1. List item
  1. List item
  1. List item
  1. List item
`, iframe: `
` } diff --git a/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts b/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts index 56f2fae691..c3ca1c183e 100644 --- a/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts +++ b/packages/ripple-tide-api/src/utils/markup-transpiler/default-plugins.ts @@ -248,6 +248,32 @@ const pluginLinks = function (this: any) { }) } +const pluginLists = function (this: any) { + this.find('ul[type], ol[type]').map((i: any, el: any) => { + const $list = this.find(el) + const type = $list.attr('type') + + const listTypes = { + 1: 'decimal', + a: 'lower-latin', + A: 'upper-latin', + i: 'lower-roman', + I: 'upper-roman', + disc: 'disc', + square: 'square', + circle: 'disc' // circles selection uses disc (a11y request) + } + + $list.removeAttr('type') + + if (listTypes[type]) { + $list.addClass(`rpl-type-list-${el?.name}--${listTypes[type]}`) + } + + return $list + }) +} + const pluginIFrames = function (this: any) { this.find('iframe').map((i: any, el: any) => { const $iframe = this.find(el) @@ -277,5 +303,6 @@ export default [ pluginImages, pluginButtons, pluginLinks, + pluginLists, pluginIFrames ] diff --git a/packages/ripple-ui-core/src/styles/utilities/_lists.css b/packages/ripple-ui-core/src/styles/utilities/_lists.css index e9d27c8f74..989acb2256 100644 --- a/packages/ripple-ui-core/src/styles/utilities/_lists.css +++ b/packages/ripple-ui-core/src/styles/utilities/_lists.css @@ -12,25 +12,29 @@ line-height: var(--rpl-type-lh-4); letter-spacing: var(--rpl-type-ls-1); margin-left: var(--rpl-sp-4); - padding-left: var(--rpl-sp-4); + padding-left: var(--rpl-sp-5); @media (--rpl-bp-l) { margin-left: var(--rpl-sp-5); } - &[type='i'] { + &.rpl-type-list-ol--decimal { + list-style-type: decimal; + } + + &.rpl-type-list-ol--lower-roman { list-style-type: lower-roman; } - &[type='I'] { + &.rpl-type-list-ol--upper-roman { list-style-type: upper-roman; } - &[type='a'] { + &.rpl-type-list-ol--lower-latin { list-style-type: lower-latin; } - &[type='A'] { + &.rpl-type-list-ol--upper-latin { list-style-type: upper-latin; } @@ -80,18 +84,22 @@ line-height: var(--rpl-type-lh-4); letter-spacing: var(--rpl-type-ls-1); margin-left: var(--rpl-sp-4); - padding-left: var(--rpl-sp-4); + padding-left: var(--rpl-sp-5); list-style-type: disc; @media (--rpl-bp-l) { margin-left: var(--rpl-sp-5); } - &[type='circle'] { + &.rpl-type-list-ul--disc { + list-style-type: disc; + } + + &.rpl-type-list-ul--circle { list-style-type: circle; } - &[type='square'] { + &.rpl-type-list-ul--square { list-style-type: square; }