actions.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Actions - Puppertino Framework</title>
  5. <link
  6. href="https://rsms.me/inter/inter.css"
  7. rel="stylesheet"
  8. />
  9. <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/codedgar/Puppertino@latest/dist/css/newfull.css" />
  10. <meta charset="utf-8" />
  11. <meta
  12. name="viewport"
  13. content="width=device-width, initial-scale=1, shrink-to-fit=no"
  14. />
  15. <meta http-equiv="x-ua-compatible" content="ie=edge" />
  16. <link rel="stylesheet" type="text/css" href="doc.css" />
  17. <meta
  18. name="description"
  19. content="This is the documentation for Actions on the Puppertino Framework, a framework that mimics Apple's design, woof!"
  20. />
  21. <link rel="icon" type="image/png" href="../landing-images/doggo.png" />
  22. <!-- Global site tag (gtag.js) - Google Analytics -->
  23. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-176821843-1"></script>
  24. <script>
  25. window.dataLayer = window.dataLayer || [];
  26. function gtag(){dataLayer.push(arguments);}
  27. gtag('js', new Date());
  28. gtag('config', 'UA-176821843-1');
  29. </script>
  30. </head>
  31. <body class="p-layout">
  32. <div class="p-action-background">
  33. <div class="p-action-big-container" id="actions" data-p-close-on-outside="true" aria-hidden="true">
  34. <div class="p-action-container">
  35. <div class="p-action-title">
  36. <h3 class="p-action-title--intern">What do you want to do?</h3>
  37. <p class="p-action-text">Select an option below...</p></div>
  38. <a href="#" class="p-action--intern p-action-destructive p-action-icon"><svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg> Close this tab</a>
  39. <a href="#" class="p-action--intern p-action-destructive p-action-icon-inline" ><svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg> Close this tab</a>
  40. <a href="#" class="p-action--intern p-action-neutral">New private tab</a>
  41. <a href="#" class="p-action--intern">New tab</a>
  42. </div>
  43. <div class="p-action-container">
  44. <a href="#" class="p-action--intern p-action-cancel" data-p-cancel-action="true">Cancel</a>
  45. </div>
  46. </div>
  47. <div class="p-action-big-container" id="actions2" data-p-close-on-outside="true" aria-hidden="true">
  48. <div class="p-action-container">
  49. <div class="p-action-title">
  50. <h3 class="p-action-title--intern">What do you want to do?</h3>
  51. <p class="p-action-text">Select an option below...</p>
  52. </div>
  53. <a href="#" class="p-action--intern p-action-neutral">New private tab</a>
  54. <a href="#" class="p-action--intern">New tab</a>
  55. </div>
  56. <div class="p-action-container">
  57. <a href="#" class="p-action--intern p-action-cancel" data-p-cancel-action="true">Cancel</a>
  58. </div>
  59. </div>
  60. <div class="p-action-big-container" id="actions_basic" data-p-close-on-outside="true" aria-hidden="true">
  61. <div class="p-action-container">
  62. <div class="p-action-title">
  63. <h3 class="p-action-title--intern">Welcome to actions</h3>
  64. <p class="p-action-text">Select an option below...</p>
  65. </div>
  66. <a href="#" class="p-action--intern p-action-neutral">New private tab</a>
  67. <a href="#" class="p-action--intern">New tab</a>
  68. </div>
  69. <div class="p-action-container">
  70. <a href="#" class="p-action--intern p-action-cancel" data-p-cancel-action="true">Cancel</a>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="route">
  75. <a
  76. href="https://codedgar.github.io/Puppertino/"
  77. class="p-btn p-btn-scope p-btn-scope-unactive"
  78. >Puppertino</a
  79. >
  80. <p>/</p>
  81. <a href="index.html" class="p-btn p-btn-scope p-btn-scope-unactive"
  82. >Examples</a
  83. >
  84. <p>/</p>
  85. <a href="actions.html" class="p-btn p-btn-scope">Actions</a>
  86. </div>
  87. <h1>Actions</h1>
  88. <div class="master">
  89. <p>
  90. Actions are a fundamental part of iOS design, so we couldn’t resist bringing them to Puppertino. Now, you can enjoy their intuitive functionality within your projects! To use actions, you can
  91. <a
  92. href="https://github.com/codedgar/Puppertino/blob/master/dist/css/actions.css"
  93. target="_blank"
  94. >Download the CSS</a
  95. >
  96. and
  97. <a
  98. href="https://github.com/codedgar/Puppertino/blob/master/src/js/full.js"
  99. target="_blank"
  100. >Download the JS.</a
  101. >
  102. Alternatively, you can use the
  103. <a
  104. href="https://github.com/codedgar/Puppertino/blob/master/dist/css/newfull.css"
  105. target="_blank"
  106. >Full CSS</a
  107. >
  108. and currently, there's not full JS.
  109. </p>
  110. <div class="talk-about-it">
  111. <h3>Note on Previous Versions</h3>
  112. <p>In earlier versions of Puppertino, actions were exclusively links. In the latest version, you now have the option to use either <strong>Buttons</strong> or <strong>Links</strong>, offering greater flexibility for appropriate actions while maintaining proper semantics and accessibility.</p>
  113. </div>
  114. <div class="talk-about-it">
  115. <h2>Let's talk about actions!</h2>
  116. <p>
  117. Actions in Puppertino function similarly to modals, prompting users to make a decision. The difference is that Actions can feature multiple decisions and are easier to acccess than modals.
  118. </p>
  119. <button data-p-open-actions="#actions2" class="p-btn">
  120. Open actions
  121. </button>
  122. </div>
  123. </div>
  124. <div class="talk-about-it">
  125. <h2>General usage.</h2>
  126. <p>
  127. Using Actions in Puppertino is nearly identical to Modals. To set up an Action, you need a container for the elements and a button to toggle it. The button should include the attribute <code class="code">data-p-open-actions</code> with the <code class="code">#id</code> of the Action you want to open, while the Action itself should have a matching ID.
  128. <br><br>
  129. Actions come with several layout variants, allowing you to arrange elements differently. However, it’s important to stick with one style per Action. Mixing variants, like combining options with icons and without, can confuse users and disrupt the visual flow, so it’s best to maintain consistency.
  130. <br><br>
  131. For added functionality, Actions also support the <code class="code">data-p-close-on-outside="true"</code> attribute, which automatically closes the Action when the user clicks outside its area.
  132. </p>
  133. <button class="p-btn" data-p-open-actions="#actions">
  134. Open actions with variants
  135. </button>
  136. <button class="p-btn" data-p-open-actions="#actions_basic">
  137. Basic Actions
  138. </button>
  139. <p>Usage:</p>
  140. <div class="code">
  141. <pre>
  142. <code class="html">
  143. &#60;!-- The button that toggles the action -->
  144. &#60;button class="p-btn" data-p-open-actions="#actions_basic">Basic Actions&#60;/button>
  145. &#60;!-- Action container, all the actions you use should be inside of it. -->
  146. &#60;div class="p-action-background">
  147. &#60;!-- Your actions will be here -->
  148. &#60;div class="p-action-big-container" id="actions_basic" data-p-close-on-outside="true">
  149. &#60;div class="p-action-container">
  150. &#60;div class="p-action-title">
  151. &#60;h3 class="p-action-title--intern">Welcome to actions&#60;/h3>
  152. &#60;p class="p-action-text">Select an option below...&#60;/p>
  153. &#60;/div>
  154. &#60;a href="#" class="p-action--intern p-action-neutral">New private tab&#60;/a>
  155. &#60;a href="#" class="p-action--intern">New tab&#60;/a>
  156. &#60;/div>
  157. &#60;div class="p-action-container">
  158. &#60;button class="p-action--intern p-action-cancel" data-p-cancel-action="true">Cancel&#60;/button>
  159. &#60;/div>
  160. &#60;/div>
  161. &#60;/div>
  162. </code>
  163. </pre>
  164. </div>
  165. <p>Variations:</p>
  166. <div class="code">
  167. <pre>
  168. <code class="html">
  169. &#60;div class="p-action-big-container" id="actions" data-p-close-on-outside="true">
  170. &#60;div class="p-action-container">
  171. &#60;div class="p-action-title">
  172. &#60;h3 class="p-action-title--intern">What do you want to do?&#60;/h3>
  173. &#60;p class="p-action-text">Select an option below...&#60;/p>&#60;/div>
  174. &#60;a href="#" class="p-action--intern p-action-destructive p-action-icon">&#60;!-- ICON --> Close this tab&#60;/a>
  175. &#60;a href="#" class="p-action--intern p-action-destructive p-action-icon-inline" >&#60;!-- ICON --> Close this tab&#60;/a>
  176. &#60;a href="#" class="p-action--intern p-action-neutral">New private tab&#60;/a>
  177. &#60;a href="#" class="p-action--intern">New tab&#60;/a>
  178. &#60;/div>
  179. &#60;div class="p-action-container">
  180. &#60;a href="#" class="p-action--intern p-action-cancel" data-p-cancel-action="true">Cancel&#60;/a>
  181. &#60;/div>
  182. &#60;/div>
  183. </code>
  184. </pre>
  185. </div>
  186. </div>
  187. <div class="talk-about-it">
  188. <section id="api-methods">
  189. <h2>JS API Methods</h2>
  190. <p>In newer versions, the old JavaScript has been replaced with the PuppertinoActionsMan class—a lightweight utility for managing action cards within the Puppertino framework.
  191. <br><br>
  192. While the way you use action cards remains unchanged thanks to automatic initialization, this class introduces programmatic methods for Opening or Closing action cards, and handling user interactions. <br><br> Here's what currently possible using Puppertino's Actions Manager.</p>
  193. <article id="open-action" class="d-flex align-bottom mt-4">
  194. <div class="flex-1 w-100">
  195. <h3>openAction(selector)</h3>
  196. <p>Opens the action card specified by the CSS selector.</p>
  197. <p><strong>Parameters:</strong></p>
  198. <ul>
  199. <li><code class="code">selector</code> (string): CSS selector for the action card to open.</li>
  200. </ul>
  201. </div>
  202. <div class="flex-1 w-100">
  203. <p><strong>Usage:</strong></p>
  204. <div class="code">
  205. <pre>
  206. <code>
  207. PuppertinoActionsManager.openAction("#exampleAction");
  208. </code>
  209. </pre>
  210. </div>
  211. </div>
  212. </article>
  213. <article id="close-active-action" class="d-flex align-bottom mt-4">
  214. <div class="flex-1 w-100">
  215. <h3>closeActiveAction()</h3>
  216. <p>Closes the currently active (open) action card.</p>
  217. </div>
  218. <div class="flex-1 w-100">
  219. <p><strong>Usage:</strong></p>
  220. <div class="code">
  221. <pre>
  222. <code>
  223. PuppertinoActionsManager.closeActiveAction();
  224. </code>
  225. </pre>
  226. </div>
  227. </div>
  228. </article>
  229. <article id="close-action" class="d-flex align-bottom mt-4">
  230. <div class="flex-1 w-100">
  231. <h3>closeAction(selector)</h3>
  232. <p>Closes a specific action card specified by the CSS selector.</p>
  233. <p><strong>Parameters:</strong></p>
  234. <ul>
  235. <li><code class="code">selector</code> (string): CSS selector for the action card to close.</li>
  236. </ul>
  237. </div>
  238. <div class="flex-1 w-100">
  239. <p><strong>Usage:</strong></p>
  240. <div class="code">
  241. <pre>
  242. <code>
  243. PuppertinoActionsManager.closeAction("#exampleAction");
  244. </code>
  245. </pre>
  246. </div>
  247. </div>
  248. </article>
  249. <article id="is-action-open" class="d-flex align-bottom mt-4">
  250. <div class="flex-1 w-100">
  251. <h3>isActionOpen(selector)</h3>
  252. <p>Checks if a specific action card is currently open.</p>
  253. <p><strong>Parameters:</strong></p>
  254. <ul>
  255. <li><code class="code">selector</code> (string): CSS selector for the action card to check.</li>
  256. </ul>
  257. <p><strong>Returns:</strong></p>
  258. <ul>
  259. <li><code class="code">true</code> if the action card is open, <code>false</code> otherwise.</li>
  260. </ul>
  261. </div>
  262. <div class="flex-1 w-100">
  263. <p><strong>Usage:</strong></p>
  264. <div class="code">
  265. <pre>
  266. <code>
  267. if (PuppertinoActionsManager.isActionOpen("#exampleAction")) {
  268. console.log("The action card is open.");
  269. }
  270. </code>
  271. </pre>
  272. </div>
  273. </div>
  274. </article>
  275. </section>
  276. </div>
  277. </body>
  278. <script src="https://cdn.jsdelivr.net/gh/codedgar/Puppertino@latest/src/js/dakmode_manager.js"></script>
  279. <script
  280. type="text/javascript"
  281. src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/highlight.min.js"
  282. ></script>
  283. <script>
  284. hljs.initHighlightingOnLoad();
  285. </script>
  286. <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/codedgar/Puppertino@latest/src/js/actions.js"></script>
  287. </html>