├── .gitignore ├── LICENSE ├── README.md ├── algolia.png ├── chakra-ui.php ├── composer.json ├── demo.gif ├── google.png ├── icon.png ├── info.plist └── screenshot.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | /vendor 3 | .idea 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Daniel Wirtz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chakra UI Docs Workflow for Alfred 2 | 3 | A Chakra UI docs search workflow for Alfred 4. 4 | 5 | ![Demo](demo.gif) 6 | 7 | Adapted from [Alfred TailwindCSS Docs](https://github.com/clnt/alfred-tailwindcss-docs), which is adapted itself from the [Alfred VueJS Docs](https://github.com/vmitchell85/alfred-vuejs-docs) and [Alfred Laravel Docs](https://github.com/tillkruss/alfred-laravel-docs). 8 | 9 | ## Installation 10 | 11 | 1. [Download the latest version](https://github.com/wirtzdan/alfred-chakra-ui-docs/releases) 12 | 2. Install the workflow by double-clicking the `.alfredworkflow` file 13 | 3. You can add the workflow to a category, then click "Import" to finish importing. You'll now see the workflow listed in the left sidebar of your Workflows preferences pane. 14 | 15 | ## Usage 16 | 17 | To search the [Chakra UI docs](https://chakra-ui.com/docs/getting-started), just type `chakra` followed by your search query. 18 | 19 | ``` 20 | chakra 21 | ``` 22 | 23 | ## Support & Feedback 24 | 25 | You can write me on [Twitter](https://twitter.com/wirtzdan/), or just open a new issue. 26 | 27 | ![Search by Algolia](algolia.png) 28 | -------------------------------------------------------------------------------- /algolia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wirtzdan/alfred-chakra-ui-docs/e58cf08271406ca65a90b3a46c516ff9149c8d8b/algolia.png -------------------------------------------------------------------------------- /chakra-ui.php: -------------------------------------------------------------------------------- 1 | initIndex('chakra-ui'); 21 | $search = $index->search($query); 22 | $results = $search['hits']; 23 | 24 | $subtextSupported = $subtext === '0' || $subtext === '2'; 25 | 26 | if (empty($results)) { 27 | if (empty($results)) { 28 | $workflow->result() 29 | ->title('No matches') 30 | ->icon('google.png') 31 | ->subtitle("No match found in the docs. Search Google for: \"Chakra+UI+{$query}\"") 32 | ->arg("https://www.google.com/search?q=chakra+ui+{$query}") 33 | ->quicklookurl("https://www.google.com/search?q=chakra+ui+{$query}") 34 | ->valid(true); 35 | 36 | echo $workflow->output(); 37 | exit; 38 | } 39 | exit; 40 | } 41 | 42 | $urls = []; 43 | 44 | 45 | foreach ($results as $hit) { 46 | $highestLvl = $hit['hierarchy']['lvl6'] ? 6 : ( 47 | $hit['hierarchy']['lvl5'] ? 5 : ( 48 | $hit['hierarchy']['lvl4'] ? 4 : ( 49 | $hit['hierarchy']['lvl3'] ? 3 : ( 50 | $hit['hierarchy']['lvl2'] ? 2 : ( 51 | $hit['hierarchy']['lvl1'] ? 1 : 0 52 | ) 53 | ) 54 | ) 55 | ) 56 | ); 57 | 58 | $title = $hit['hierarchy']['lvl' . $highestLvl]; 59 | $currentLvl = 0; 60 | $subtitle = $hit['hierarchy']['lvl0']; 61 | while ($currentLvl < $highestLvl) { 62 | $currentLvl = $currentLvl + 1; 63 | $subtitle = $subtitle . ' » ' . $hit['hierarchy']['lvl' . $currentLvl]; 64 | } 65 | 66 | $workflow->result() 67 | ->uid($hit['objectID']) 68 | ->title($title) 69 | ->autocomplete($title) 70 | ->subtitle($subtitle) 71 | ->arg($hit['url']) 72 | ->quicklookurl($hit['url']) 73 | ->valid(true); 74 | } 75 | 76 | echo $workflow->output(); 77 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wirtzdan/alfred-chakra-ui-docs", 3 | "description": "Chakra UI docs search workflow for Alfred 4.", 4 | "version": "1.0.0", 5 | "keywords": [ 6 | "alfred", 7 | "alfred-workflow", 8 | "chakra-ui", 9 | "algolia" 10 | ], 11 | "homepage": "https://github.com/wirtzdan", 12 | "support": { 13 | "source": "https://github.com/wirtzdan/alfred-chakra-ui-docs", 14 | "issues": "https://github.com/wirtzdan/alfred-chakra-ui-docs/issues" 15 | }, 16 | "license": "MIT", 17 | "require": { 18 | "joetannenbaum/alfred-workflow": "^0.1.0", 19 | "algolia/algoliasearch-client-php": "^1.27", 20 | "erusev/parsedown": "^1.7" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wirtzdan/alfred-chakra-ui-docs/e58cf08271406ca65a90b3a46c516ff9149c8d8b/demo.gif -------------------------------------------------------------------------------- /google.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wirtzdan/alfred-chakra-ui-docs/e58cf08271406ca65a90b3a46c516ff9149c8d8b/google.png -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wirtzdan/alfred-chakra-ui-docs/e58cf08271406ca65a90b3a46c516ff9149c8d8b/icon.png -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.wirtzdan.chakra-ui-docs 7 | category 8 | Productivity 9 | connections 10 | 11 | 7DC430D5-A7C8-4D12-B10E-144E763EACEE 12 | 13 | 14 | destinationuid 15 | 6D7BB70F-AA13-48F8-B4A5-6185D7B944B2 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | vitoclose 21 | 22 | 23 | 24 | 25 | createdby 26 | Daniel Wirtz 27 | description 28 | Chakra UI docs search workflow 29 | disabled 30 | 31 | name 32 | Chakra UI Search 33 | objects 34 | 35 | 36 | config 37 | 38 | alfredfiltersresults 39 | 40 | alfredfiltersresultsmatchmode 41 | 0 42 | argumenttreatemptyqueryasnil 43 | 44 | argumenttrimmode 45 | 0 46 | argumenttype 47 | 0 48 | escaping 49 | 127 50 | keyword 51 | chakra 52 | queuedelaycustom 53 | 3 54 | queuedelayimmediatelyinitially 55 | 56 | queuedelaymode 57 | 0 58 | queuemode 59 | 1 60 | runningsubtext 61 | Searching docs for "{query}"... 62 | script 63 | php chakra-ui.php "{query}" 64 | scriptargtype 65 | 0 66 | scriptfile 67 | 68 | subtext 69 | Search the Chakra UI docs... 70 | title 71 | Search the Chakra UI docs... 72 | type 73 | 0 74 | withspace 75 | 76 | 77 | type 78 | alfred.workflow.input.scriptfilter 79 | uid 80 | 7DC430D5-A7C8-4D12-B10E-144E763EACEE 81 | version 82 | 3 83 | 84 | 85 | config 86 | 87 | browser 88 | 89 | spaces 90 | 91 | url 92 | {query} 93 | utf8 94 | 95 | 96 | type 97 | alfred.workflow.action.openurl 98 | uid 99 | 6D7BB70F-AA13-48F8-B4A5-6185D7B944B2 100 | version 101 | 1 102 | 103 | 104 | readme 105 | 106 | uidata 107 | 108 | 6D7BB70F-AA13-48F8-B4A5-6185D7B944B2 109 | 110 | xpos 111 | 495 112 | ypos 113 | 170 114 | 115 | 7DC430D5-A7C8-4D12-B10E-144E763EACEE 116 | 117 | colorindex 118 | 7 119 | xpos 120 | 115 121 | ypos 122 | 170 123 | 124 | 125 | webaddress 126 | https://github.com/wirtzdan/alfred-chakra-ui-docs 127 | 128 | 129 | -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wirtzdan/alfred-chakra-ui-docs/e58cf08271406ca65a90b3a46c516ff9149c8d8b/screenshot.jpg --------------------------------------------------------------------------------